Phase 1 of the ptid_t changes.

This commit is contained in:
Kevin Buettner 2001-05-04 04:15:33 +00:00
parent b1af961c84
commit 39f770628a
132 changed files with 2660 additions and 2053 deletions

View File

@ -1,3 +1,383 @@
2001-05-03 Kevin Buettner <kevinb@redhat.com>
* defs.h (ptid_t): New typedef.
(pid_to_ptid, null_ptid, minus_one_ptid, ptid_equal): New macros.
* a68v-nat.c, alphabsd-nat.c, arch-utils.c, arm-linux-nat.c,
blockframe.c, breakpoint.c, breakpoint.h,
config/i386/nm-i386sol2.h, config/i386/tm-i386sco5.h,
config/ia64/nm-linux.h, config/m68k/nm-hp300bsd.h,
config/mips/nm-irix4.h, config/mips/nm-irix5.h,
config/pa/nm-hppah.h, config/pa/tm-hppa.h,
config/rs6000/nm-rs6000.h, config/sparc/nm-sun4sol2.h,
corelow.c, cxux-nat.c, d10v-tdep.c, dink32-rom.c,
dve3900-rom.c, fork-child.c, frame.c, gnu-nat.c, go32-nat.c,
hp300ux-nat.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c,
hpux-thread.c, i386-linux-nat.c, i386aix-nat.c, i386b-nat.c,
i386bsd-nat.c, i386gnu-nat.c, i386mach-nat.c, i386nbsd-nat.c,
infcmd.c, inferior.h, inflow.c, infptrace.c, infrun.c,
inftarg.c, infttrace.c, lin-lwp.c, lin-thread.c,
linux-thread.c, lynx-nat.c, m3-nat.c, m32r-rom.c,
m68knbsd-nat.c, m88k-nat.c, mac-nat.c, mips-nat.c,
mon960-rom.c, monitor.c, ns32knbsd-nat.c, ocd.c, ppc-bdm.c,
ppcnbsd-nat.c, proc-service.c, procfs.c, ptx4-nat.c,
regcache.c, remote-adapt.c, remote-array.c, remote-bug.c,
remote-e7000.c, remote-es.c, remote-mips.c, remote-mm.c,
remote-nindy.c, remote-os9k.c, remote-rdi.c, remote-rdp.c,
remote-sds.c, remote-sim.c, remote-st.c, remote-udi.c,
remote-vx.c, remote.c, rs6000-nat.c, sol-thread.c,
solib-aix5.c, solib-svr4.c, somsolib.c, sparc-nat.c,
standalone.c, sun3-nat.c, sun386-nat.c, symm-nat.c, target.c,
target.h, thread-db.c, thread.c, top.c, ultra3-nat.c,
uw-thread.c, v850ice.c, win32-nat.c, wince.c, xcoffsolib.c
(inferior_pid): Rename to inferior_ptid everywhere - even in
comments and obsolete ports. In cases where this variable
really is supposed to be used as a process id, use PIDGET() to
extract the process id component from inferior_ptid. The
other cases, either involving other variables whose types had
to be changed or functions whose signatures had to changed
are listed separately below.
* arm-linux-nat.c (get_thread_id): Change type of argument
representing a combined process/thread id from ``int'' to
``ptid_t''. Also change parameter name to ptid.
* breakpoint.h, breakpoint.c (breakpoint_thread_match): Likewise.
* corelow.c (core_file_thread_alive): Likewise.
* d10v-tdep.c (d10v_read_pc, d10v_write_pc): Likewise.
* defs.h (*target_wait_hook): Likewise.
* gdbthread.h (thread_info, delete_thread, pid_to_thread_id)
(find_thread_pid, save_infrun_state, load_infrun_state): Likewise.
* gnu-nat.c (gnu_thread_alive, gnu_pid_to_str, gnu_wait)
(gnu_resume): Likewise.
* go32-nat.c (go32_wait, go32_resume): Likewise.
* h8500-tdep.c (h8500_read_pc, h8500_write_pc): Likewise.
* hppa-tdep.c (target_read_pc, target_write_pc): Likewise.
* hppah-nat.c (child_pid_to_str, hppa_tid_to_str,
(hppa_pid_or_tid_to_str, child_post_startup_inferior)
(child_thread_alive): Likewise.
* hpux-thread.c (hpux_thread_notice_signals, hpux_thread_alive)
(hpux_pid_to_str, hpux_thread_wait, hpux_thread_resume): Likewise.
* i386-linux-nat.c (child_resume): Likewise.
* ia64-linux-nat.c (enable_watchpoints_in_psr, fetch_debug_register)
(store_debug_register, fetch_debug_register_pair)
(store_debug_register_pair, ia64_linux_insert_watchpoint)
(ia64_linux_remove_watchpoint, ia64_linux_stopped_by_watchpoint):
Likewise.
* ia64-tdep.c (ia64_read_pc, ia64_write_pc): Likewise.
* inferior.h (read_pc_pid, generic_target_read_pc, write_pc_pid)
(generic_target_write_pc, ptrace_wait, child_resume)
(get_last_target_status): Likewise.
* infptrace.c (ptrace_wait, child_resume): Likewise.
* inftarg.c (child_wait, child_post_wait, child_thread_live)
(child_pid_to_str): Likewise.
* infttrace.c (ptrace_wait, child_thread_alive, child_resume)
(hppa_pid_or_tid_to_str, child_post_startup_inferior): Likewise.
* lin-lwp.c (add_lwp, delete_lwp, find_lwp_pid, lin_lwp_attach_lwp)
(lin_lwp_resume, lin_lwp_wait, lin_lwp_thread_alive)
(lin_lwp_pid_to_str): Likewise.
* lin-thread.c (thread_db_alive, thread_db_pid_to_str)
(thread_db_resume, thread_db_wait): Likewise.
* linux-thread.c (linuxthreads_thread_alive, linuxthreads_pid_to_str)
(linuxthreads_resume, linuxthreads_wait): Likewise.
* lynx-nat.c (child_wait, child_thread_alive, child_resume)
(child_pid_to_str): Likewise.
* m3-nat.c (mach_really_wait, m3_resume): Likewise.
* mac-nat.c (child_wait, child_resume): Likewise.
* mips-tdep.c (mips_read_pc): Likewise.
* monitor.c (monitor_wait, monitor_resume): Likewise.
* ocd.c, ocd.h (ocd_thread_alive, ocd_resume): Likewise.
* ppc-bdm.c (bdm_ppc_wait): Likewise.
* procfs.c (do_attach, procfs_wait, procfs_resume)
(procfs_notice_signals, procfs_thread_alive, procfs_pid_to_str)
(procfs_set_watchpoint, procfs_stopped_by_watchpoint)
(procfs_find_LDT_entry): Likewise.
* regcache.c (read_register_pid, read_signed_register_pid)
(write_register_pid, generic_target_read_pc, read_pc_pid)
(generic_target_write_pc, write_pc_pid): Likewise.
* regcache.h (read_register_pid, read_signed_register_pid)
(write_register_pid): Likewise.
* remote-adapt.c (adapt_wait, adapt_resume): Likewise.
* remote-array.c (array_wait, array_resume): Likewise.
* remote-bug.c (bug_wait, bug_resume): Likewise.
* remote-e7000.c (e7000_wait, e7000_resume): Likewise.
* remote-eb.c (eb_wait, eb_resume): Likewise.
* remote-es.c (es1800_wait, es1800_resume): Likewise.
* remote-mips.c (mips_wait, mips_resume): Likewise.
* remote-mm.c (mm_wait, mm_resume): Likewise.
* remote-nindy.c (nindy_wait, nindy_resume): Likewise.
* remote-os9k.c (rombug_wait, rombug_resume): Likewise.
* remote-rdi.c (arm_rdi_wait, arm_rdi_resume): Likewise.
* remote-rdp.c (remote_rdp_resume, remote_rdp_wait): Likewise.
* remote-sds.c (sds_wait, sds_resume): Likewise.
* remote-sim.c (gdbsim_wait, gdbsim_resume): Likewise.
* remote-st.c (st2000_wait, st2000_resume): Likewise.
* remote-udi.c (udi_wait, udi_resume): Likewise.
* remote-vx.c (vx_wait, vx_resume): Likewise.
* remote.c (remote_current_thread, remote_resume, remote_wait)
(remote_async_resume, remote_async_wait, remote_cisco_wait)
(remote_thread_alive): Likewise.
* sol-thread.c (thread_to_lwp, lwp_to_thread, sol_thread_resume)
(sol_thread_wait, sol_thread_notice_signals, sol_thread_alive)
(solaris_pid_to_str): Likewise.
* symm-nat.c (child_wait, child_resume): Likewise.
* target.c (debug_to_resume, debug_to_wait, debug_to_post_wait)
(debug_to_notice_signals, debug_to_thread_alive)
(normal_target_post_startup_inferior, normal_pid_to_str)
(debug_to_post_startup_inferior): Likewise.
* target.h (to_resume, to_wait, to_post_wait)
(to_post_startup_inferior, to_notice_signals, to_thread_alive)
(to_pid_to_str [all in struct target_ops]): Likewise.
(child_post_wait, child_thread_alive, normal_pid_to_str): Likewise.
* thread-db.c (thread_from_lwp, lwp_from_thread, thread_db_wait)
(attach_thread, detach_thread, thread_db_resume, check_event)
(thread_db_post_startup_inferior, thread_db_thread_alive)
(thread_db_pid_to_str): Likewise.
* thread.c (add_thread, delete_thread, find_thread_pid)
(pid_to_thread_id, in_thread_list, load_infrun_state)
(save_infrun_state, switch_to_thread, restore_current_thread)
(make_cleanup_restore_current_thread): Likewise.
* top.c (target_wait_hook): Likewise.
* uw-thread.c (dbgpid, thr_to_lwp, lwp_to_thr, add_thread_uw)
(uw_thread_resume, libtrhead_stub, uw_thread_wait, uw_thread_alive)
(uw_thread_pid_to_str): Likewise.
* v850ice.c (v850ice_wait, v850ice_resume): Likewise.
* win32-nat.c (child_wait, child_resume, win32_child_thread_alive)
(cywin_pid_to_str): Likewise.
* wince.c (child_wait, child_resume, win32_child_thread_alive):
Likewise.
* config/nm-linux.h (linuxthreads_pid_to_str): Likewise.
* config/nm-lynx.h (child_wait, lynx_pid_to_str): Likewise.
* config/alpha/nm-linux.h (lin_lwp_attach_lwp): Likewise.
* config/arm/nm-linux.h (lin_lwp_attach_lwp): Likewise.
* config/h8500/tm-h8500.h (h8500_read_pc, h8500_write_pc): Likewise.
* config/i386/nm-i386sol2.h (procfs_stopped_by_watchpoint)
(procfs_set_watchpoint): Likewise.
* config/i386/nm-linux.h (lin_lwp_attach_lwp): Likewise.
* config/i386/nm-ptx4.h (child_wait): Likewise.
* config/i386/nm-symmetry.h (child_wait): Likewise.
* config/i386/tm-cygwin.h (cygwin_pid_to_str): Likewise.
* config/ia64/nm-linux.h (ia64_linux_stopped_by_watchpoint)
(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint)
(lin_lwp_attach_lwp): Likewise.
* config/mips/nm-irix4.h, config/mips/nm-irix5.h
(procfs_stopped_by_watchpoint, procfs_set_watchpoint): Likewise.
* config/pa/nm-hppah.h (child_pid_to_str, hppa_tid_to_str)
(hppa_pid_or_tid_to_str): Likewise.
* config/pa/tm-hppa.h (target_read_pc, target_write_pc): Likewise.
* config/powerpc/nm-linux.h (lin_lwp_attach_lwp): Likewise.
* config/sparc/nm-sun4sol2.h (procfs_stopped_by_watchpoint)
(procfs_set_watchpoint): Likewise.
* gdbthread.h (thread_id_to_pid): Change return type which
represents a combined process/thread id from ``int'' to
``ptid_t''.
* gnu-nat.c (gnu_wait): Likewise.
* go32-nat.c (go32_wait): Likewise.
* hpux-thread.c (hpux_thread_wait): Likewise.
* inferior.h (procfs_first_available): Likewise.
* inftarg.c (child_wait): Likewise.
* infttrace.c (ptrace_wait): Likewise.
* lin-lwp.c (lin_lwp_wait): Likewise.
* lin-thread.c (thread_db_wait): Likewise.
* linux-thread.c (linuxthreads_wait): Likewise.
* lynx-nat.c (child_wait): Likewise.
* m3-nat.c (mach_really_wait): Likewise.
* mac-nat.c (child_wait): Likewise.
* monitor.c (monitor_wait): Likewise.
* ppc-bdm.c (bdm_ppc_wait): Likewise.
* procfs.c (do_attach, procfs_wait, procfs_first_available): Likewise.
* remote-adapt.c (adapt_wait): Likewise.
* remote-array.c (array_wait): Likewise.
* remote-bug.c (bug_wait): Likewise.
* remote-e7000.c (e7000_wait): Likewise.
* remote-eb.c (eb_wait): Likewise.
* remote-es.c (es1800_wait): Likewise.
* remote-mips.c (mips_wait): Likewise.
* remote-mm.c (mm_wait): Likewise.
* remote-nindy.c (nindy_wait): Likewise.
* remote-os9k (rombug_wait): Likewise.
* remote-rdi.c (arm_rdi_wait): Likewise.
* remote-rdp.c (remote_rdp_wait): Likewise.
* remote-sds.c (sds_wait): Likewise.
* remote-sim.c (gdbsim_wait): Likewise.
* remote-st.c (st2000_wait): Likewise.
* remote-udi.c (udi_wait): Likewise.
* remote-vx.c (vx_wait): Likewise.
* remote.c (remote_wait, remote_async_wait, remote_current_thread)
(remote_cisco_wait): Likewise.
* sol-thread.c (thread_to_lwp, lwp_to_thread, sol_thread_wait):
Likewise.
* symm-nat.c (child_wait): Likewise.
* target.c (debug_to_wait): Likewise.
* target.h (to_wait [in struct target_ops]): Likewise.
* thread.c (thread_id_to_pid): Likewise.
* thread-db.c (thread_from_lwp, lwp_from_thread, thread_db_wait):
Likewise.
* top.c (*target_wait_hook): Likewise.
* uw-thread.c (lwp_to_thr, uw_thread_wait): Likewise.
* v850ice.c (v850ice_wait): Likewise.
* win32-nat.c (child_wait): Likewise.
* wince.c (child_wait): Likewise.
* config/nm-lynx.h (child_wait): Likewise.
* config/i386/nm-ptx4.h (child_wait): Likewise.
* config/i386/nm-symmetry.h (child_wait): Likewise.
* arch-utils.c (generic_prepare_to_proceed): Rename wait_pid
to wait_ptid and change its type from ``int'' to ``ptid_t''.
* breakpoint.c (reattach_breakpoints, detach_breakpoints): Likewise,
but rename saved_inferior_pid to saved_inferior_ptid.
* d10v-tdep.c (d10v_read_pc, d10_write_pc): Likewise, but rename
save_pid to save_ptid.
* gdbthread.h (struct thread_info): Likewise, but rename pid to ptid.
* hppah-nat.c (child_pid_to_exec): Likewise, but rename
saved_inferior_pid to saved_inferior_ptid.
* hpux-thread.c (main_ptid): Likewise, but rename from main_pid.
* infrun.c (previous_inferior_pid [static global]): Likewise,
but rename to previous_inferior_ptid.
(resume): Likewise, but rename resume_pid to resume_ptid.
(struct execution_control_state): Likewise, but rename
pid to ptid, saved_inferior_pid to saved_inferior_ptid,
and waiton_pid to waiton_ptid.
(target_last_wait_pid): Likewise, but rename to
target_last_wait_ptid.
* infttrace.c (saved_real_pid): Likewise, but rename to
saved_real_ptid.
(child_pid_to_exec_file): Likewise, but rename saved_inferior_pid
to saved_inferior_ptid.
* lin-lwp.c (struct lwp_info): Likewise, but rename pid to ptid.
(trap_ptid): Likewise, but renamed from trap_pid.
* lin-thread.c (handle_new_thread): Likewise, but rename gdb_pid
to gdb_ptid.
* linux-thread.c (detach_thread): Likewise, but rename pid to ptid.
(thread_db_wait): Likewise, but rename ret_pid to retptid.
* procfs.c (procfs_wait): Likewise, for retval whose name
doesn't change. Also, ``temp'' becomes two separate variables,
one named temp_tid (an int) and the other temp_ptid.
(procfs_notice_thread): Likewise (type change) for gdb_threadid
whose name does not change.
* regcache.c (registers_ptid): Likewise, but renamed from
registers_pid.
(read_register_pid, read_signed_register_pid, write_register_pid):
Likewise, but rename save_pid to save_ptid.
(read_pc_pid, write_pc_pid): Likewise, but rename saved_inferior_pid
to saved_inferior_ptid.
* remote.c (remote_newthread_step): Likewise, but rename pid to ptid.
* sol-thread.c (struct ps_prochandle): Likewise.
(sol_thread_resume): Likewise, for save_pid which becomes save_ptid.
(sol_thread_wait): Likewise, for rtnval whose name does not
change, and for save_pid which becomes save_ptid.
(solaris_pid_to_str): Likewise for lwp whose name does not change.
(sol_find_new_threads_callback): Likewise, for pid which becomes
ptid.
* target.h (target_resume, target_wait, target_post_wait)
(target_post_startup_inferior, target_notice_signals)
(target_thread_alive): Likewise.
* thread.c (info_threads_command): Likewise, but rename
current_pid to current_ptid.
(struct current_thread_cleanup): Likewise, but rename field
inferior_pid to inferior_ptid.
* thread-db.c (find_new_threads_callback): Likewise, but rename
pid to ptid.
* uw-thread.c (thr_to_lwp): Likewise for lid whose name does not
change.
(lwp_to_tr): Likewise fo tid whose name remains unchanged.
(thr_infpid, lwp_infpid, notice_thread, libthread_stub): Likewise,
but rename pid to ptid.
* config/alpha/nm-linux.h (ATTACH_LWP): Likewise.
* config/arm/nm-linux.h (ATTACH_LWP): Likewise.
* config/i386/nm-linux.h (ATTACH_LWP): Likewise.
* config/ia64/nm-linux.h (ATTACH_LWP): Likewise.
* config/pa/nm-hppah.h (target_tid_to_str): Likewise.
* config/powerpc/nm-linux.h (ATTACH_LWP): Likewise.
* arch-utils.c (generic_prepare_to_proceed): Test for the
"zero" ptid by using ptid_equal() to test to see if variable
in question is the same as null_ptid. This replaces a direct
test against zero.
* cxux-nat.c (add_shared_symbol_files): Likewise.
* i386aix-nat.c, i386b-nat.c (i386_float_info): Likewise.
* infcmd.c (run_command): Likewise.
* inflow.c (kill_command): Likewise.
* infttrace.c (call_ttrace): Likewise.
* lin-lwp.c (lin_lwp_prepare_to_proceed): Likewise.
* lin-thread.c (thread_db_kill): Likewise.
* procfs.c (procfs_kill_inferior, procfs_mourn_inferior): Likewise.
* remote-es.c (es1800_kill): Likewise.
* sol-thread.c (sol_thread_create_inferior): Likewise.
* solib.c (locate_base): Likewise.
* target.c (nosupport_runtime): Likewise.
* thread-db.c (thread_db_wait): Likewise.
* top.c (quit_confirm, quit_force): Likewise.
* uw-thread (lwp_infpid, uw_thread_resume): Likewise.
* infrun.c (handle_inferior_event, stop_stepping, normal_stop):
Use ptid_equal to compare value of process/thread ids instead of
``=='' and ``!='' operators.
lin-lwp.c (delete_lwp, lin_lwp_prepare_to_proceed)
(stop_wait_callback, lin_lwp_wait): Likewise.
* procfs.c (procfs_wait): Likewise.
* regcache.c (read_register_bytes, read_register_gen)
(write_register_gen, read_register, read_register_pid)
(read_signed_register, read_signed_register_pid, write_register)
(write_register_pid, supply_register): Likewise.
* remote-vx.c (vx_resume): Likewise.
* sol-thread.c (sol_thread_wait): Likewise.
* symm-nat.c (kill_inferior): Likewise.
* thread.c (delete_thread, find_thread_pid, pid_to_thread_id)
(in_thread_list, info_threads_command, switch_to_thread)
(restore_current_thread): Likewise.
* uw-thread (libtread_stub): Likewise.
* arm-linux-nat.c (GET_THREAD_ID): Change PID to PTID.
* corelow.c (add_to_thread_list): Convert argument in add_thread()
call to a ptid_t.
* gnu-nat.c (inf_validate_procs): Likewise.
* linux-thread.c (stop_thread, update_stop_threads): Likewise.
* remote.c (record_currthread, remote_threads_info): Likewise.
* win32-nat.c (child_add_thread): Likewise.
* hpux-thread.c (save_inferior_pid, restore_inferior_pid): Rename,
respectively, to save_inferior_ptid() and restore_inferior_ptid().
Adjust implementations to operate on ``ptid_t'' instead of ``int''.
* lin-lwp.c (save_inferior_pid, restore_inferior_pid): Likewise.
* lin-thread.c (save_inferior_pid, restore_inferior_pid): Likewise.
* linux-thread.c (save_inferior_pid, restore_inferior_pid): Likewise.
* proc-service.c (save_inferior_pid, restore_inferior_pid): Likewise.
* sol-thread.c (save_inferior_pid, restore_inferior_pid): Likewise.
* thread-db.c (save_inferior_pid, restore_inferior_pid): Likewise.
* infrun.c (RESUME_ALL): New macro representing the -1 ptid
to be passed to target_resume() when all threads should resume.
(resume): Set resume_ptid to RESUME_ALL rather than -1.
(handle_inferior_event): Invoke target_resume() with RESUME_ALL
instead of -1.
* irix5-nat.c (solib_create_inferior_hook): Convert -1 to
a ptid_t in target_resume() call.
* osfsolib.c (solib_create_inferior_hook): Likewise.
* solib-svr4.c (solib_create_inferior_hook): Likewise.
* lin-lwp.c (PIDGET, PIDGET0): Rename original PIDGET macro to
PIDGET0. Define new PIDGET macro which uses PIDGET0, the only
difference being that the 0xffff pattern will be interpreted
as -1.
* lin-thread.c (PIDGET, PIDGET0): Likewise.
* thread-db.c (PIDGET, PIDGET0): Likewise.
* config/nm-linux.h (PIDGET, PIDGET0): Likewise.
* config/i386/tm-i386sol2.h (PIDGET, PIDGET0): Likewise.
* config/i386/tm-i386v42mp.h (PIDGET, PIDGET0): Likewise.
* config/sparc/tm-sun4sol2.h (PIDGET, PIDGET0): Likewise.
* m3-nat.c (init_m3_ops): Fix typo; initialize to_wait field to
mach_really_wait rather than mach_really__wait.
* lin-thread.c (check_for_thread_event): Fix warning; make function
actually return a value.
* gdbarch.sh (TARGET_READ_PC, TARGET_WRITE_PC): Change type of
``pid'' arguments from ``int'' to ``ptid_t''. Also renamed
pid to ptid.
* gdbarch.h, gdbarch.c: Regenerated.
2001-05-03 Jonathan Larmour <jlarmour@redhat.com>
* rdi-share/devsw.c: Include <time.h> for struct tm

View File

@ -43,19 +43,19 @@ fetch_inferior_registers (int ignored)
registers_fetched ();
ptrace (PTRACE_GETREGS, inferior_pid,
ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers,
ptrace_$data_set,
(PTRACE_ARG3_TYPE) & inferior_registers,
ptrace_$data_set);
ptrace (PTRACE_GETREGS, inferior_pid,
ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_fp_registers,
ptrace_$floating_set_m68k,
(PTRACE_ARG3_TYPE) & inferior_fp_registers,
ptrace_$floating_set_m68k);
ptrace (PTRACE_GETREGS, inferior_pid,
ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_control_registers,
ptrace_$control_set_m68k,
(PTRACE_ARG3_TYPE) & inferior_control_registers,
@ -82,13 +82,13 @@ store_inferior_registers (int regno)
ptrace_$init_control (&inferior_control_registers);
inferior_fp_registers.size = sizeof (inferior_fp_registers);
ptrace (PTRACE_GETREGS, inferior_pid,
ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_fp_registers,
ptrace_$floating_set_m68k,
(PTRACE_ARG3_TYPE) & inferior_fp_registers,
ptrace_$floating_set_m68k);
ptrace (PTRACE_GETREGS, inferior_pid,
ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_control_registers,
ptrace_$control_set_m68k,
(PTRACE_ARG3_TYPE) & inferior_control_registers,
@ -102,19 +102,19 @@ store_inferior_registers (int regno)
inferior_control_registers.sr = *(int *) &registers[REGISTER_BYTE (PS_REGNUM)];
inferior_control_registers.pc = *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];
ptrace (PTRACE_SETREGS, inferior_pid,
ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers,
ptrace_$data_set_m68k,
(PTRACE_ARG3_TYPE) & inferior_registers,
ptrace_$data_set_m68k);
ptrace (PTRACE_SETREGS, inferior_pid,
ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_fp_registers,
ptrace_$floating_set_m68k,
(PTRACE_ARG3_TYPE) & inferior_fp_registers,
ptrace_$floating_set_m68k);
ptrace (PTRACE_SETREGS, inferior_pid,
ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_control_registers,
ptrace_$control_set_m68k,
(PTRACE_ARG3_TYPE) & inferior_control_registers,

View File

@ -135,7 +135,8 @@ fetch_inferior_registers (int regno)
{
gregset_t gregs;
if (ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &gregs, 0) == -1)
perror_with_name ("Couldn't get registers");
supply_gregset (&gregs);
@ -144,7 +145,7 @@ fetch_inferior_registers (int regno)
{
fpregset_t fpregs;
if (ptrace (PT_GETFPREGS, inferior_pid,
if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
perror_with_name ("Couldn't get floating point status");
@ -163,25 +164,27 @@ store_inferior_registers (int regno)
{
gregset_t gregs;
if (ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &gregs, 0) == -1)
perror_with_name ("Couldn't get registers");
fill_gregset (&gregs, regno);
if (ptrace (PT_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &gregs, 0) == -1)
perror_with_name ("Couldn't write registers");
if (regno == -1 || regno >= FP0_REGNUM)
{
fpregset_t fpregs;
if (ptrace (PT_GETFPREGS, inferior_pid,
if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
perror_with_name ("Couldn't get floating point status");
fill_fpregset (&fpregs, regno);
if (ptrace (PT_SETFPREGS, inferior_pid,
if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
perror_with_name ("Couldn't write floating point status");
}

View File

@ -252,11 +252,11 @@ default_prepare_to_proceed (int select_it)
int
generic_prepare_to_proceed (int select_it)
{
int wait_pid;
ptid_t wait_ptid;
struct target_waitstatus wait_status;
/* Get the last target status returned by target_wait(). */
get_last_target_status (&wait_pid, &wait_status);
get_last_target_status (&wait_ptid, &wait_status);
/* Make sure we were stopped at a breakpoint. */
if (wait_status.kind != TARGET_WAITKIND_STOPPED
@ -265,10 +265,11 @@ generic_prepare_to_proceed (int select_it)
return 0;
}
if (wait_pid != -1 && inferior_pid != wait_pid)
if (!ptid_equal (wait_ptid, minus_one_ptid)
&& !ptid_equal (inferior_ptid, wait_ptid))
{
/* Switched over from WAIT_PID. */
CORE_ADDR wait_pc = read_pc_pid (wait_pid);
CORE_ADDR wait_pc = read_pc_pid (wait_ptid);
/* Avoid switching where it wouldn't do any good, i.e. if both
threads are at the same breakpoint. */
@ -278,7 +279,7 @@ generic_prepare_to_proceed (int select_it)
{
/* User hasn't deleted the breakpoint. Switch back to
WAIT_PID and return non-zero. */
inferior_pid = wait_pid;
inferior_ptid = wait_ptid;
/* FIXME: This stuff came from switch_to_thread() in
thread.c (which should probably be a public function). */

View File

@ -78,7 +78,7 @@ static unsigned int os_version, os_major, os_minor, os_release;
/* On Linux, threads are implemented as pseudo-processes, in which
case we may be tracing more than one process at a time. In that
case, inferior_pid will contain the main process ID and the
case, inferior_ptid will contain the main process ID and the
individual thread (process) ID mashed together. These macros are
used to separate them out. These definitions should be overridden
if thread support is included. */
@ -89,13 +89,14 @@ static unsigned int os_version, os_major, os_minor, os_release;
#endif
int
get_thread_id (int inferior_pid)
get_thread_id (ptid_t ptid)
{
int tid = TIDGET (inferior_pid);
if (0 == tid) tid = inferior_pid;
int tid = TIDGET (ptid);
if (0 == tid)
tid = PIDGET (ptid);
return tid;
}
#define GET_THREAD_ID(PID) get_thread_id ((PID));
#define GET_THREAD_ID(PTID) get_thread_id ((PTID));
static void
fetch_nwfpe_single (unsigned int fn, FPA11 * fpa11)
@ -230,7 +231,7 @@ fetch_fpregister (int regno)
FPA11 fp;
/* Get the thread id for the ptrace call. */
tid = GET_THREAD_ID (inferior_pid);
tid = GET_THREAD_ID (inferior_ptid);
/* Read the floating point state. */
ret = ptrace (PT_GETFPREGS, tid, 0, &fp);
@ -279,7 +280,7 @@ fetch_fpregs (void)
FPA11 fp;
/* Get the thread id for the ptrace call. */
tid = GET_THREAD_ID (inferior_pid);
tid = GET_THREAD_ID (inferior_ptid);
/* Read the floating point state. */
ret = ptrace (PT_GETFPREGS, tid, 0, &fp);
@ -327,7 +328,7 @@ store_fpregister (int regno)
FPA11 fp;
/* Get the thread id for the ptrace call. */
tid = GET_THREAD_ID (inferior_pid);
tid = GET_THREAD_ID (inferior_ptid);
/* Read the floating point state. */
ret = ptrace (PT_GETFPREGS, tid, 0, &fp);
@ -365,7 +366,7 @@ store_fpregs (void)
FPA11 fp;
/* Get the thread id for the ptrace call. */
tid = GET_THREAD_ID (inferior_pid);
tid = GET_THREAD_ID (inferior_ptid);
/* Read the floating point state. */
ret = ptrace (PT_GETFPREGS, tid, 0, &fp);
@ -403,7 +404,7 @@ fetch_register (int regno)
struct pt_regs regs;
/* Get the thread id for the ptrace call. */
tid = GET_THREAD_ID (inferior_pid);
tid = GET_THREAD_ID (inferior_ptid);
ret = ptrace (PTRACE_GETREGS, tid, 0, &regs);
if (ret < 0)
@ -440,7 +441,7 @@ fetch_regs (void)
struct pt_regs regs;
/* Get the thread id for the ptrace call. */
tid = GET_THREAD_ID (inferior_pid);
tid = GET_THREAD_ID (inferior_ptid);
ret = ptrace (PTRACE_GETREGS, tid, 0, &regs);
if (ret < 0)
@ -474,7 +475,7 @@ store_register (int regno)
return;
/* Get the thread id for the ptrace call. */
tid = GET_THREAD_ID (inferior_pid);
tid = GET_THREAD_ID (inferior_ptid);
/* Get the general registers from the process. */
ret = ptrace (PTRACE_GETREGS, tid, 0, &regs);
@ -502,7 +503,7 @@ store_regs (void)
struct pt_regs regs;
/* Get the thread id for the ptrace call. */
tid = GET_THREAD_ID (inferior_pid);
tid = GET_THREAD_ID (inferior_ptid);
/* Fetch the general registers. */
ret = ptrace (PTRACE_GETREGS, tid, 0, &regs);

View File

@ -265,8 +265,8 @@ reinit_frame_cache (void)
{
flush_cached_frames ();
/* FIXME: The inferior_pid test is wrong if there is a corefile. */
if (inferior_pid != 0)
/* FIXME: The inferior_ptid test is wrong if there is a corefile. */
if (PIDGET (inferior_ptid) != 0)
{
select_frame (get_current_frame (), 0);
}

View File

@ -988,13 +988,13 @@ insert_breakpoints (void)
switch (b->type)
{
case bp_catch_fork:
val = target_insert_fork_catchpoint (inferior_pid);
val = target_insert_fork_catchpoint (PIDGET (inferior_ptid));
break;
case bp_catch_vfork:
val = target_insert_vfork_catchpoint (inferior_pid);
val = target_insert_vfork_catchpoint (PIDGET (inferior_ptid));
break;
case bp_catch_exec:
val = target_insert_exec_catchpoint (inferior_pid);
val = target_insert_exec_catchpoint (PIDGET (inferior_ptid));
break;
default:
warning ("Internal error, %s line %d.", __FILE__, __LINE__);
@ -1061,10 +1061,10 @@ reattach_breakpoints (int pid)
{
register struct breakpoint *b;
int val;
int saved_inferior_pid = inferior_pid;
ptid_t saved_inferior_ptid = inferior_ptid;
/* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
inferior_pid = pid; /* Because remove_breakpoint will use this global. */
/* FIXME: use a cleanup, to insure that inferior_ptid gets replaced! */
inferior_ptid = pid_to_ptid (pid); /* Because remove_breakpoint will use this global. */
ALL_BREAKPOINTS (b)
{
if (b->inserted)
@ -1076,12 +1076,12 @@ reattach_breakpoints (int pid)
val = target_insert_breakpoint (b->address, b->shadow_contents);
if (val != 0)
{
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return val;
}
}
}
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return 0;
}
@ -1205,13 +1205,13 @@ detach_breakpoints (int pid)
{
register struct breakpoint *b;
int val;
int saved_inferior_pid = inferior_pid;
ptid_t saved_inferior_ptid = inferior_ptid;
if (pid == inferior_pid)
error ("Cannot detach breakpoints of inferior_pid");
if (pid == PIDGET (inferior_ptid))
error ("Cannot detach breakpoints of inferior_ptid");
/* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
inferior_pid = pid; /* Because remove_breakpoint will use this global. */
/* FIXME: use a cleanup, to insure that inferior_ptid gets replaced! */
inferior_ptid = pid_to_ptid (pid); /* Because remove_breakpoint will use this global. */
ALL_BREAKPOINTS (b)
{
if (b->inserted)
@ -1219,12 +1219,12 @@ detach_breakpoints (int pid)
val = remove_breakpoint (b, mark_inserted);
if (val != 0)
{
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return val;
}
}
}
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return 0;
}
@ -1347,13 +1347,13 @@ remove_breakpoint (struct breakpoint *b, insertion_state_t is)
switch (b->type)
{
case bp_catch_fork:
val = target_remove_fork_catchpoint (inferior_pid);
val = target_remove_fork_catchpoint (PIDGET (inferior_ptid));
break;
case bp_catch_vfork:
val = target_remove_vfork_catchpoint (inferior_pid);
val = target_remove_vfork_catchpoint (PIDGET (inferior_ptid));
break;
case bp_catch_exec:
val = target_remove_exec_catchpoint (inferior_pid);
val = target_remove_exec_catchpoint (PIDGET (inferior_ptid));
break;
default:
warning ("Internal error, %s line %d.", __FILE__, __LINE__);
@ -1565,12 +1565,12 @@ frame_in_dummy (struct frame_info *frame)
PC is valid for process/thread PID. */
int
breakpoint_thread_match (CORE_ADDR pc, int pid)
breakpoint_thread_match (CORE_ADDR pc, ptid_t ptid)
{
struct breakpoint *b;
int thread;
thread = pid_to_thread_id (pid);
thread = pid_to_thread_id (ptid);
ALL_BREAKPOINTS (b)
if (b->enable != disabled
@ -2422,10 +2422,11 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_breakpoint)
ignore it. */
if ((b->type == bp_catch_load)
#if defined(SOLIB_HAVE_LOAD_EVENT)
&& (!SOLIB_HAVE_LOAD_EVENT (inferior_pid)
&& (!SOLIB_HAVE_LOAD_EVENT (PIDGET (inferior_ptid))
|| ((b->dll_pathname != NULL)
&& (strcmp (b->dll_pathname,
SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid))
SOLIB_LOADED_LIBRARY_PATHNAME (
PIDGET (inferior_ptid)))
!= 0)))
#endif
)
@ -2433,25 +2434,28 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_breakpoint)
if ((b->type == bp_catch_unload)
#if defined(SOLIB_HAVE_UNLOAD_EVENT)
&& (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid)
&& (!SOLIB_HAVE_UNLOAD_EVENT (PIDGET (inferior_ptid))
|| ((b->dll_pathname != NULL)
&& (strcmp (b->dll_pathname,
SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid))
SOLIB_UNLOADED_LIBRARY_PATHNAME (
PIDGET (inferior_ptid)))
!= 0)))
#endif
)
continue;
if ((b->type == bp_catch_fork)
&& !target_has_forked (inferior_pid, &b->forked_inferior_pid))
&& !target_has_forked (PIDGET (inferior_ptid),
&b->forked_inferior_pid))
continue;
if ((b->type == bp_catch_vfork)
&& !target_has_vforked (inferior_pid, &b->forked_inferior_pid))
&& !target_has_vforked (PIDGET (inferior_ptid),
&b->forked_inferior_pid))
continue;
if ((b->type == bp_catch_exec)
&& !target_has_execd (inferior_pid, &b->exec_pathname))
&& !target_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))
continue;
if (ep_is_exception_catchpoint (b) &&
@ -3034,9 +3038,11 @@ bpstat_get_triggered_catchpoints (bpstat ep_list, bpstat *cp_list)
if (ep->triggered_dll_pathname != NULL)
xfree (ep->triggered_dll_pathname);
if (ep->type == bp_catch_load)
dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid);
dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (
PIDGET (inferior_ptid));
else
dll_pathname = SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid);
dll_pathname = SOLIB_UNLOADED_LIBRARY_PATHNAME (
PIDGET (inferior_ptid));
#else
dll_pathname = NULL;
#endif
@ -4319,8 +4325,8 @@ set_momentary_breakpoint (struct symtab_and_line sal, struct frame_info *frame,
/* If we're debugging a multi-threaded program, then we
want momentary breakpoints to be active in only a
single thread of control. */
if (in_thread_list (inferior_pid))
b->thread = pid_to_thread_id (inferior_pid);
if (in_thread_list (inferior_ptid))
b->thread = pid_to_thread_id (inferior_ptid);
return b;
}
@ -5324,7 +5330,7 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
startup sequence by the dynamic linker.
However, I tried avoiding that by having HP-UX's implementation of
TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_ptid
yet, which forced slow watches before a "run" or "attach", and it
still fails somewhere in the startup code.
@ -6056,7 +6062,7 @@ catch_load_command_1 (char *arg, int tempflag, int from_tty)
/* Create a load breakpoint that only triggers when a load of
the specified dll (or any dll, if no pathname was specified)
occurs. */
SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid, tempflag,
SOLIB_CREATE_CATCH_LOAD_HOOK (PIDGET (inferior_ptid), tempflag,
dll_pathname, cond_string);
}
@ -6098,7 +6104,7 @@ catch_unload_command_1 (char *arg, int tempflag, int from_tty)
/* Create an unload breakpoint that only triggers when an unload of
the specified dll (or any dll, if no pathname was specified)
occurs. */
SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid, tempflag,
SOLIB_CREATE_CATCH_UNLOAD_HOOK (PIDGET (inferior_ptid), tempflag,
dll_pathname, cond_string);
}
#endif /* SOLIB_ADD */
@ -7138,14 +7144,14 @@ breakpoint_re_set (void)
/* Reset the thread number of this breakpoint:
- If the breakpoint is for all threads, leave it as-is.
- Else, reset it to the current thread for inferior_pid. */
- Else, reset it to the current thread for inferior_ptid. */
void
breakpoint_re_set_thread (struct breakpoint *b)
{
if (b->thread != -1)
{
if (in_thread_list (inferior_pid))
b->thread = pid_to_thread_id (inferior_pid);
if (in_thread_list (inferior_ptid))
b->thread = pid_to_thread_id (inferior_ptid);
}
}

View File

@ -521,7 +521,7 @@ extern int breakpoint_inserted_here_p (CORE_ADDR);
extern int frame_in_dummy (struct frame_info *);
extern int breakpoint_thread_match (CORE_ADDR, int);
extern int breakpoint_thread_match (CORE_ADDR, ptid_t);
extern void until_break_command (char *, int);
@ -598,7 +598,7 @@ extern void update_breakpoints_after_exec (void);
be detached and allowed to run free.
It is an error to use this function on the process whose id is
inferior_pid. */
inferior_ptid. */
extern int detach_breakpoints (int);
extern void enable_longjmp_breakpoint (void);

View File

@ -74,8 +74,8 @@ extern int lin_lwp_prepare_to_proceed (void);
#undef PREPARE_TO_PROCEED
#define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed ()
extern void lin_lwp_attach_lwp (int pid, int verbose);
#define ATTACH_LWP(pid, verbose) lin_lwp_attach_lwp ((pid), (verbose))
extern void lin_lwp_attach_lwp (ptid_t pid, int verbose);
#define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose))
#include <signal.h>

View File

@ -38,8 +38,8 @@ extern int lin_lwp_prepare_to_proceed (void);
#undef PREPARE_TO_PROCEED
#define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed ()
extern void lin_lwp_attach_lwp (int pid, int verbose);
#define ATTACH_LWP(pid, verbose) lin_lwp_attach_lwp ((pid), (verbose))
extern void lin_lwp_attach_lwp (ptid_t ptid, int verbose);
#define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose))
#include <signal.h>

View File

@ -283,8 +283,8 @@ extern void h8500_write_sp (CORE_ADDR);
extern CORE_ADDR h8500_read_fp (void);
extern void h8500_write_fp (CORE_ADDR);
extern CORE_ADDR h8500_read_pc (int);
extern void h8500_write_pc (CORE_ADDR, int);
extern CORE_ADDR h8500_read_pc (ptid_t);
extern void h8500_write_pc (CORE_ADDR, ptid_t);
#define TARGET_READ_SP() h8500_read_sp()
#define TARGET_WRITE_SP(x) h8500_write_sp(x)

View File

@ -44,17 +44,17 @@
step anyway. */
#define CANNOT_STEP_HW_WATCHPOINTS
extern int procfs_stopped_by_watchpoint (int);
extern int procfs_stopped_by_watchpoint (ptid_t);
#define STOPPED_BY_WATCHPOINT(W) \
procfs_stopped_by_watchpoint(inferior_pid)
procfs_stopped_by_watchpoint(inferior_ptid)
/* Use these macros for watchpoint insertion/deletion. */
/* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */
extern int procfs_set_watchpoint (int, CORE_ADDR, int, int, int);
extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int);
#define target_insert_watchpoint(ADDR, LEN, TYPE) \
procfs_set_watchpoint (inferior_pid, ADDR, LEN, TYPE, 1)
procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 1)
#define target_remove_watchpoint(ADDR, LEN, TYPE) \
procfs_set_watchpoint (inferior_pid, ADDR, 0, 0, 0)
procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0)
#endif /* NEW_PROC_API */

View File

@ -90,8 +90,8 @@ extern int lin_lwp_prepare_to_proceed (void);
#undef PREPARE_TO_PROCEED
#define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed ()
extern void lin_lwp_attach_lwp (int pid, int verbose);
#define ATTACH_LWP(pid, verbose) lin_lwp_attach_lwp ((pid), (verbose))
extern void lin_lwp_attach_lwp (ptid_t ptid, int verbose);
#define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose))
#include <signal.h>

View File

@ -42,7 +42,7 @@
#define CHILD_WAIT
struct target_waitstatus;
extern int child_wait (int, struct target_waitstatus *);
extern ptid_t child_wait (ptid_t, struct target_waitstatus *);
/*
* ptx does attach as of ptx version 2.1. Prior to that, the interface

View File

@ -32,7 +32,7 @@
#ifdef _SEQUENT_
#define CHILD_WAIT
extern int child_wait (int, struct target_waitstatus *);
extern ptid_t child_wait (ptid_t, struct target_waitstatus *);
#endif
/* This is the amount to subtract from u.u_ar0

View File

@ -38,7 +38,7 @@ extern CORE_ADDR skip_trampoline_code (CORE_ADDR pc, char *name);
#define ADD_SHARED_SYMBOL_FILES dll_symbol_command
struct target_ops;
char *cygwin_pid_to_str (int pid);
char *cygwin_pid_to_str (ptid_t ptid);
void child_solib_add (char *, int, struct target_ops *);
char *child_solib_loaded_library_pathname(int);
void child_clear_solibs (void);

View File

@ -52,12 +52,12 @@
#define HAVE_STEPPABLE_WATCHPOINT
#define STOPPED_BY_WATCHPOINT(W) \
i386_stopped_by_watchpoint (inferior_pid)
i386_stopped_by_watchpoint (PIDGET (inferior_ptid))
#define target_insert_watchpoint(addr, len, type) \
i386_insert_watchpoint (inferior_pid, addr, len, type)
i386_insert_watchpoint (PIDGET (inferior_ptid), addr, len, type)
#define target_remove_watchpoint(addr, len, type) \
i386_remove_watchpoint (inferior_pid, addr, len)
i386_remove_watchpoint (PIDGET (inferior_ptid), addr, len)
#endif /* ifndef TM_I386SCO5_H */

View File

@ -54,7 +54,8 @@ extern char *sunpro_static_transform_name (char *);
/* Macros to extract process id and thread id from a composite pid/tid.
Allocate lower 16 bits for process id, next 15 bits for thread id, and
one bit for a flag to indicate a user thread vs. a kernel thread. */
#define PIDGET(PID) (((PID) & 0xffff))
#define PIDGET0(PID) (((PID) & 0xffff))
#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID))
#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16)
#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16))

View File

@ -43,7 +43,8 @@
#define PIDBITS 16
/* Return the process id stored in composite PID. */
#define PIDGET(PID) (((PID) & ((1 << PIDBITS) - 1)))
#define PIDGET0(PID) (((PID) & ((1 << PIDBITS) - 1)))
#define PIDGET(PID) ((PIDGET0 (PID) == ((1 << PIDBITS) -1)) ? -1 : PIDGET0 (PID))
/* Return the thread or lwp id stored in composite PID. */
#define TIDGET(PID) (((PID) & 0x3fffffff) >> PIDBITS)

View File

@ -63,17 +63,18 @@ extern int ia64_register_u_addr(int, int);
#define HAVE_STEPPABLE_WATCHPOINT 1
#define STOPPED_BY_WATCHPOINT(W) \
ia64_linux_stopped_by_watchpoint (inferior_pid)
extern CORE_ADDR ia64_linux_stopped_by_watchpoint (int);
ia64_linux_stopped_by_watchpoint (inferior_ptid)
extern CORE_ADDR ia64_linux_stopped_by_watchpoint (ptid_t ptid);
#define target_insert_watchpoint(addr, len, type) \
ia64_linux_insert_watchpoint (inferior_pid, addr, len, type)
extern int ia64_linux_insert_watchpoint (int pid, CORE_ADDR addr,
ia64_linux_insert_watchpoint (inferior_ptid, addr, len, type)
extern int ia64_linux_insert_watchpoint (ptid_t ptid, CORE_ADDR addr,
int len, int rw);
#define target_remove_watchpoint(addr, len, type) \
ia64_linux_remove_watchpoint (inferior_pid, addr, len)
extern int ia64_linux_remove_watchpoint (int pid, CORE_ADDR addr, int len);
ia64_linux_remove_watchpoint (inferior_ptid, addr, len)
extern int ia64_linux_remove_watchpoint (ptid_t ptid, CORE_ADDR addr,
int len);
/* FIXME: kettenis/2000-09-03: This should be moved to ../nm-linux.h
once we have converted all Linux targets to use the new threads
@ -83,8 +84,8 @@ extern int lin_lwp_prepare_to_proceed (void);
#undef PREPARE_TO_PROCEED
#define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed ()
extern void lin_lwp_attach_lwp (int pid, int verbose);
#define ATTACH_LWP(pid, verbose) lin_lwp_attach_lwp ((pid), (verbose))
extern void lin_lwp_attach_lwp (ptid_t ptid, int verbose);
#define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose))
#include <signal.h>

View File

@ -40,7 +40,7 @@
/* U_REGS_OFFSET is the offset of the registers within the u area for
ptrace purposes. */
#define U_REGS_OFFSET \
ptrace (PT_READ_U, inferior_pid, \
ptrace (PT_READ_U, PIDGET (inferior_ptid), \
(PTRACE_ARG3_TYPE) \
(offsetof (struct user, u_kproc.kp_proc.p_md.md_regs)), 0) \
- USRSTACK

View File

@ -51,17 +51,17 @@
GDB to step over the watchpoint. */
#define STOPPED_BY_WATCHPOINT(W) \
procfs_stopped_by_watchpoint(inferior_pid)
extern int procfs_stopped_by_watchpoint (int);
procfs_stopped_by_watchpoint(inferior_ptid)
extern int procfs_stopped_by_watchpoint (ptid_t);
#define HAVE_NONSTEPPABLE_WATCHPOINT
/* Use these macros for watchpoint insertion/deletion. */
/* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */
#define target_insert_watchpoint(ADDR, LEN, TYPE) \
procfs_set_watchpoint (inferior_pid, ADDR, LEN, TYPE, 0)
procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 0)
#define target_remove_watchpoint(ADDR, LEN, TYPE) \
procfs_set_watchpoint (inferior_pid, ADDR, 0, 0, 0)
extern int procfs_set_watchpoint (int, CORE_ADDR, int, int, int);
procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0)
extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int);
#define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(SIZE) 1

View File

@ -31,17 +31,17 @@
GDB to step over the watchpoint. */
#define STOPPED_BY_WATCHPOINT(W) \
procfs_stopped_by_watchpoint(inferior_pid)
extern int procfs_stopped_by_watchpoint (int);
procfs_stopped_by_watchpoint(inferior_ptid)
extern int procfs_stopped_by_watchpoint (ptid_t);
#define HAVE_NONSTEPPABLE_WATCHPOINT
/* Use these macros for watchpoint insertion/deletion. */
/* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */
#define target_insert_watchpoint(ADDR, LEN, TYPE) \
procfs_set_watchpoint (inferior_pid, ADDR, LEN, TYPE, 0)
procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 0)
#define target_remove_watchpoint(ADDR, LEN, TYPE) \
procfs_set_watchpoint (inferior_pid, ADDR, 0, 0, 0)
extern int procfs_set_watchpoint (int, CORE_ADDR, int, int, int);
procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0)
extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int);
#define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(SIZE) 1

View File

@ -41,7 +41,7 @@ struct objfile;
extern void linuxthreads_new_objfile (struct objfile *objfile);
/* Method to print a human-readable thread description */
extern char *linuxthreads_pid_to_str (int pid);
extern char *linuxthreads_pid_to_str (ptid_t ptid);
extern int linuxthreads_prepare_to_proceed (int step);
#define PREPARE_TO_PROCEED(select_it) linuxthreads_prepare_to_proceed (1)
@ -52,7 +52,8 @@ extern int linuxthreads_prepare_to_proceed (int step);
/* Macros to extract process id and thread id from a composite pid/tid.
Allocate lower 19 bits for process id, next 12 bits for thread id, and
one bit for a flag to indicate a user thread vs. a kernel thread. */
#define PIDGET(PID) (((PID) & 0xffff))
#define PIDGET0(PID) (((PID) & 0xffff))
#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID))
#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16)
#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16))

View File

@ -71,7 +71,8 @@
#include "target.h"
extern int child_wait (int pid, struct target_waitstatus *status);
extern ptid_t child_wait (ptid_t ptid,
struct target_waitstatus *status);
/* Lynx needs a special definition of this so that we can
print out the pid and thread number seperately. */
@ -79,6 +80,6 @@ extern int child_wait (int pid, struct target_waitstatus *status);
/* override child_pid_to_str in inftarg.c */
#define CHILD_PID_TO_STR
extern char *lynx_pid_to_str (int pid);
extern char *lynx_pid_to_str (ptid_t ptid);
#endif /* NM_LYNX_H */

View File

@ -219,21 +219,21 @@ extern void hppa_disable_page_protection_events (int);
/* Use these macros for watchpoint insertion/deletion. */
#define target_insert_watchpoint(addr, len, type) \
hppa_insert_hw_watchpoint (inferior_pid, addr, (LONGEST)(len), type)
hppa_insert_hw_watchpoint (PIDGET (inferior_ptid), addr, (LONGEST)(len), type)
#define target_remove_watchpoint(addr, len, type) \
hppa_remove_hw_watchpoint (inferior_pid, addr, (LONGEST)(len), type)
hppa_remove_hw_watchpoint (PIDGET (inferior_ptid), addr, (LONGEST)(len), type)
/* We call our k-thread processes "threads", rather
* than processes. So we need a new way to print
* the string. Code is in hppah-nat.c.
*/
extern char *child_pid_to_str (pid_t);
extern char *child_pid_to_str (ptid_t);
#define target_tid_to_str( pid ) \
hppa_tid_to_str( pid )
extern char *hppa_tid_to_str (pid_t);
#define target_tid_to_str( ptid ) \
hppa_tid_to_str( ptid )
extern char *hppa_tid_to_str (ptid_t);
/* For this, ID can be either a process or thread ID, and the function
will describe it appropriately, returning the description as a printable
@ -244,7 +244,7 @@ extern char *hppa_tid_to_str (pid_t);
*/
#define target_pid_or_tid_to_str(ID) \
hppa_pid_or_tid_to_str (ID)
extern char *hppa_pid_or_tid_to_str (pid_t);
extern char *hppa_pid_or_tid_to_str (ptid_t);
/* This is used when handling events caused by a call to vfork(). On ptrace-
based HP-UXs, when you resume the vforked child, the parent automagically

View File

@ -767,12 +767,12 @@ extern CORE_ADDR skip_trampoline_code (CORE_ADDR, char *);
#endif
#define TARGET_READ_PC(pid) target_read_pc (pid)
extern CORE_ADDR target_read_pc (int);
extern CORE_ADDR target_read_pc (ptid_t);
#define TARGET_WRITE_PC(v,pid) target_write_pc (v,pid)
extern void target_write_pc (CORE_ADDR, int);
extern void target_write_pc (CORE_ADDR, ptid_t);
#define TARGET_READ_FP() target_read_fp (inferior_pid)
#define TARGET_READ_FP() target_read_fp (PIDGET (inferior_ptid))
extern CORE_ADDR target_read_fp (int);
/* For a number of horrible reasons we may have to adjust the location

View File

@ -45,8 +45,8 @@ extern int lin_lwp_prepare_to_proceed (void);
#undef PREPARE_TO_PROCEED
#define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed ()
extern void lin_lwp_attach_lwp (int pid, int verbose);
#define ATTACH_LWP(pid, verbose) lin_lwp_attach_lwp ((pid), (verbose))
extern void lin_lwp_attach_lwp (ptid_t ptid, int verbose);
#define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose))
#include <signal.h>

View File

@ -44,9 +44,9 @@
and figure out where the shared libraries have got to. */
#define SOLIB_ADD(a, b, c) \
if (inferior_pid) \
if (PIDGET (inferior_ptid)) \
/* Attach to process. */ \
xcoff_relocate_symtab (inferior_pid); \
xcoff_relocate_symtab (PIDGET (inferior_ptid)); \
else \
/* Core file. */ \
xcoff_relocate_core (c);

View File

@ -53,17 +53,17 @@
It will *NOT* be necessary for GDB to step over the watchpoint. */
#define HAVE_CONTINUABLE_WATCHPOINT
extern int procfs_stopped_by_watchpoint (int);
extern int procfs_stopped_by_watchpoint (ptid_t);
#define STOPPED_BY_WATCHPOINT(W) \
procfs_stopped_by_watchpoint(inferior_pid)
procfs_stopped_by_watchpoint(inferior_ptid)
/* Use these macros for watchpoint insertion/deletion. */
/* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */
extern int procfs_set_watchpoint (int, CORE_ADDR, int, int, int);
extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int);
#define target_insert_watchpoint(ADDR, LEN, TYPE) \
procfs_set_watchpoint (inferior_pid, ADDR, LEN, TYPE, 1)
procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 1)
#define target_remove_watchpoint(ADDR, LEN, TYPE) \
procfs_set_watchpoint (inferior_pid, ADDR, 0, 0, 0)
procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0)
#endif /* NEW_PROC_API */

View File

@ -82,6 +82,7 @@ extern char *sunpro_static_transform_name (char *);
#define HANDLE_SVR4_EXEC_EMULATORS
/* Macros to extract process id and thread id from a composite pid/tid */
#define PIDGET(PID) (((PID) & 0xffff))
#define PIDGET0(PID) (((PID) & 0xffff))
#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID))
#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16)
#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16))

View File

@ -77,7 +77,7 @@ static void add_to_thread_list (bfd *, asection *, PTR);
static int ignore (CORE_ADDR, char *);
static int core_file_thread_alive (int tid);
static int core_file_thread_alive (ptid_t tid);
static void init_core_ops (void);
@ -185,7 +185,7 @@ core_close (int quitting)
if (core_bfd)
{
inferior_pid = 0; /* Avoid confusion from thread stuff */
inferior_ptid = null_ptid; /* Avoid confusion from thread stuff */
/* Clear out solib state while the bfd is still open. See
comments in clear_solib in solib.c. */
@ -242,13 +242,20 @@ add_to_thread_list (bfd *abfd, asection *asect, PTR reg_sect_arg)
thread_id = atoi (bfd_section_name (abfd, asect) + 5);
add_thread (thread_id);
add_thread (pid_to_ptid (thread_id));
/* Warning, Will Robinson, looking at BFD private data! */
if (reg_sect != NULL
&& asect->filepos == reg_sect->filepos) /* Did we find .reg? */
inferior_pid = thread_id; /* Yes, make it current */
#ifdef pid_to_ptid
/* Needed to prevent regressions in ptid conversion phase 1. This
bit of code will be deleted in favor of the #else branch in
phase 3. */
inferior_ptid = thread_id; /* Yes, make it current */
#else
inferior_ptid = pid_to_ptid (thread_id); /* Yes, make it current */
#endif
}
/* This routine opens and sets up the core file bfd. */
@ -384,10 +391,10 @@ core_detach (char *args, int from_tty)
them to core_vec->core_read_registers, as the register set numbered
WHICH.
If inferior_pid is zero, do the single-threaded thing: look for a
section named NAME. If inferior_pid is non-zero, do the
If inferior_ptid is zero, do the single-threaded thing: look for a
section named NAME. If inferior_ptid is non-zero, do the
multi-threaded thing: look for a section named "NAME/PID", where
PID is the shortest ASCII decimal representation of inferior_pid.
PID is the shortest ASCII decimal representation of inferior_ptid.
HUMAN_NAME is a human-readable name for the kind of registers the
NAME section contains, for use in error messages.
@ -406,8 +413,16 @@ get_core_register_section (char *name,
bfd_size_type size;
char *contents;
if (inferior_pid)
sprintf (section_name, "%s/%d", name, inferior_pid);
#ifdef pid_to_ptid
/* Needed to prevent regressions in ptid conversion phase 1. This
bit of code will be deleted in favor of the #else branch in
phase 3. */
if (inferior_ptid)
sprintf (section_name, "%s/%d", name, inferior_ptid);
#else
if (PIDGET (inferior_ptid))
sprintf (section_name, "%s/%d", name, PIDGET (inferior_ptid));
#endif
else
strcpy (section_name, name);
@ -485,7 +500,7 @@ ignore (CORE_ADDR addr, char *contents)
behaviour.
*/
static int
core_file_thread_alive (int tid)
core_file_thread_alive (ptid_t tid)
{
return 1;
}

View File

@ -80,7 +80,7 @@ fetch_inferior_registers (int regno)
offset = (char *) &u.pt_r0 - (char *) &u;
regaddr = offset; /* byte offset to r0; */
/* offset = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
/* offset = ptrace (3, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
for (regno = 0; regno < PC_REGNUM; regno++)
{
/*regaddr = register_addr (regno, offset); */
@ -88,29 +88,29 @@ fetch_inferior_registers (int regno)
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
{
*(int *) &buf[i] = ptrace (3, inferior_pid,
*(int *) &buf[i] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, 0);
regaddr += sizeof (int);
}
supply_register (regno, buf);
}
/* now load up registers 32-37; special pc registers */
*(int *) &buf[0] = ptrace (3, inferior_pid,
*(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) PSR_OFFSET, 0);
supply_register (PSR_REGNUM, buf);
*(int *) &buf[0] = ptrace (3, inferior_pid,
*(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) FPSR_OFFSET, 0);
supply_register (FPSR_REGNUM, buf);
*(int *) &buf[0] = ptrace (3, inferior_pid,
*(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) FPCR_OFFSET, 0);
supply_register (FPCR_REGNUM, buf);
*(int *) &buf[0] = ptrace (3, inferior_pid,
*(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SXIP_OFFSET, 0);
supply_register (SXIP_REGNUM, buf);
*(int *) &buf[0] = ptrace (3, inferior_pid,
*(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SNIP_OFFSET, 0);
supply_register (SNIP_REGNUM, buf);
*(int *) &buf[0] = ptrace (3, inferior_pid,
*(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SFIP_OFFSET, 0);
supply_register (SFIP_REGNUM, buf);
@ -122,13 +122,13 @@ fetch_inferior_registers (int regno)
{
X_REGISTER_RAW_TYPE xval;
*(int *) &xval.w1 = ptrace (3, inferior_pid,
*(int *) &xval.w1 = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, 0);
*(int *) &xval.w2 = ptrace (3, inferior_pid,
*(int *) &xval.w2 = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) (regaddr + 4), 0);
*(int *) &xval.w3 = ptrace (3, inferior_pid,
*(int *) &xval.w3 = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) (regaddr + 8), 0);
*(int *) &xval.w4 = ptrace (3, inferior_pid,
*(int *) &xval.w4 = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) (regaddr + 12), 0);
supply_register (regno, (void *) &xval);
}
@ -161,7 +161,7 @@ store_inferior_registers (int regno)
{
regaddr = offset + regno * sizeof (int);
errno = 0;
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, read_register (regno));
if (errno != 0)
{
@ -170,22 +170,22 @@ store_inferior_registers (int regno)
}
}
else if (regno == PSR_REGNUM)
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) PSR_OFFSET, read_register (regno));
else if (regno == FPSR_REGNUM)
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) FPSR_OFFSET, read_register (regno));
else if (regno == FPCR_REGNUM)
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) FPCR_OFFSET, read_register (regno));
else if (regno == SXIP_REGNUM)
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SXIP_OFFSET, read_register (regno));
else if (regno == SNIP_REGNUM)
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SNIP_OFFSET, read_register (regno));
else if (regno == SFIP_REGNUM)
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SFIP_OFFSET, read_register (regno));
else if (target_is_m88110 && regno < NUM_REGS)
{
@ -194,10 +194,10 @@ store_inferior_registers (int regno)
read_register_bytes (REGISTER_BYTE (regno), (char *) &xval,
sizeof (X_REGISTER_RAW_TYPE));
regaddr = XREGADDR (regno);
ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, xval.w1);
ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr + 4, xval.w2);
ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr + 8, xval.w3);
ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr + 12, xval.w4);
ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr, xval.w1);
ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr + 4, xval.w2);
ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr + 8, xval.w3);
ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr + 12, xval.w4);
}
else
printf_unfiltered ("Bad register number for store_inferior routine\n");
@ -209,7 +209,7 @@ store_inferior_registers (int regno)
/* regaddr = register_addr (regno, offset); */
errno = 0;
regaddr = offset + regno * sizeof (int);
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, read_register (regno));
if (errno != 0)
{
@ -217,17 +217,17 @@ store_inferior_registers (int regno)
perror_with_name (buf);
}
}
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) PSR_OFFSET, read_register (regno));
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) FPSR_OFFSET, read_register (regno));
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) FPCR_OFFSET, read_register (regno));
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SXIP_OFFSET, read_register (SXIP_REGNUM));
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SNIP_OFFSET, read_register (SNIP_REGNUM));
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SFIP_OFFSET, read_register (SFIP_REGNUM));
if (target_is_m88110)
{
@ -238,10 +238,10 @@ store_inferior_registers (int regno)
read_register_bytes (REGISTER_BYTE (regno), (char *) &xval,
sizeof (X_REGISTER_RAW_TYPE));
regaddr = XREGADDR (regno);
ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, xval.w1);
ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) (regaddr + 4), xval.w2);
ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) (regaddr + 8), xval.w3);
ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) (regaddr + 12), xval.w4);
ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr, xval.w1);
ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) (regaddr + 4), xval.w2);
ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) (regaddr + 8), xval.w3);
ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) (regaddr + 12), xval.w4);
}
}
}
@ -361,7 +361,7 @@ add_shared_symbol_files (void)
struct objfile *objfile;
char *path_name;
if (!inferior_pid)
if (ptid_equal (inferior_ptid, null_ptid))
{
warning ("The program has not yet been started.");
return;

View File

@ -885,29 +885,29 @@ show_regs (char *args, int from_tty)
}
CORE_ADDR
d10v_read_pc (int pid)
d10v_read_pc (ptid_t ptid)
{
int save_pid;
ptid_t save_ptid;
CORE_ADDR pc;
CORE_ADDR retval;
save_pid = inferior_pid;
inferior_pid = pid;
save_ptid = inferior_ptid;
inferior_ptid = ptid;
pc = (int) read_register (PC_REGNUM);
inferior_pid = save_pid;
inferior_ptid = save_ptid;
retval = D10V_MAKE_IADDR (pc);
return retval;
}
void
d10v_write_pc (CORE_ADDR val, int pid)
d10v_write_pc (CORE_ADDR val, ptid_t ptid)
{
int save_pid;
ptid_t save_ptid;
save_pid = inferior_pid;
inferior_pid = pid;
save_ptid = inferior_ptid;
inferior_ptid = ptid;
write_register (PC_REGNUM, D10V_CONVERT_IADDR_TO_RAW (val));
inferior_pid = save_pid;
inferior_ptid = save_ptid;
}
CORE_ADDR

View File

@ -843,6 +843,38 @@ enum val_prettyprint
/* Use the default setting which the user has specified. */
Val_pretty_default
};
/* A collection of the various "ids" necessary for identifying
the inferior. This consists of the process id (pid, thread
id (tid), and other fields necessary for uniquely identifying
the inferior process/thread being debugged.
The present typedef is obviously quite naive with respect to
the magnitudes that real life pids and tids can take on and
will be replaced with something more robust shortly. */
typedef int ptid_t;
/* Convert a pid to a ptid_t. This macro is temporary and will
be replaced shortly. */
#define pid_to_ptid(PID) ((ptid_t) MERGEPID ((PID),0))
/* Define a value for the null (or zero) pid. This macro is temporary
and will go away shortly. */
#define null_ptid (pid_to_ptid (0))
/* Define a value for the -1 pid. This macro is temporary and will go
away shortly. */
#define minus_one_ptid (pid_to_ptid (-1))
/* Define a ptid comparison operator. This macro is temporary and will
be replaced with a real function shortly. */
#define ptid_equal(PTID1,PTID2) ((PTID1) == (PTID2))
/* Optional host machine definition. Pure autoconf targets will not
@ -1302,7 +1334,8 @@ extern void (*readline_end_hook) (void);
extern void (*register_changed_hook) (int regno);
extern void (*memory_changed_hook) (CORE_ADDR addr, int len);
extern void (*context_hook) (int);
extern int (*target_wait_hook) (int pid, struct target_waitstatus * status);
extern ptid_t (*target_wait_hook) (ptid_t ptid,
struct target_waitstatus * status);
extern void (*attach_hook) (void);
extern void (*detach_hook) (void);

View File

@ -99,15 +99,13 @@ dink32_supply_register (char *regname, int regnamelen, char *val, int vallen)
static void
dink32_load (struct monitor_ops *monops, char *filename, int from_tty)
{
extern int inferior_pid;
generic_load (filename, from_tty);
/* Finally, make the PC point at the start address */
if (exec_bfd)
write_pc (bfd_get_start_address (exec_bfd));
inferior_pid = 0; /* No process now */
inferior_ptid = null_ptid; /* No process now */
}

View File

@ -927,7 +927,7 @@ r3900_load (char *filename, int from_tty)
if (exec_bfd)
write_pc (bfd_get_start_address (exec_bfd));
inferior_pid = 0; /* No process now */
inferior_ptid = null_ptid; /* No process now */
/* This is necessary because many things were based on the PC at the
time that we attached to the monitor, which is no longer valid

View File

@ -89,7 +89,7 @@ breakup_args (char *scratch, char **argv)
}
/* Start an inferior Unix child process and sets inferior_pid to its pid.
/* Start an inferior Unix child process and sets inferior_ptid to its pid.
EXEC_FILE is the file to run.
ALLARGS is a string containing the arguments to the program.
ENV is the environment vector to pass. SHELL_FILE is the shell file,
@ -355,7 +355,7 @@ fork_inferior (char *exec_file_arg, char *allargs, char **env,
init_thread_list ();
inferior_pid = pid; /* Needed for wait_for_inferior stuff below */
inferior_ptid = pid_to_ptid (pid); /* Needed for wait_for_inferior stuff below */
/* Now that we have a child process, make it our target, and
initialize anything target-vector-specific that needs initializing. */
@ -462,7 +462,7 @@ clone_and_follow_inferior (int child_pid, int *followed_child)
sleep (debug_fork);
/* The child (i.e., the cloned debugger) must now attach to
CHILD_PID. inferior_pid is presently set to the parent process
CHILD_PID. inferior_ptid is presently set to the parent process
of the fork, while CHILD_PID should be the child process of the
fork.
@ -471,10 +471,10 @@ clone_and_follow_inferior (int child_pid, int *followed_child)
*/
read (handoff_semaphore[SEM_LISTEN], &listen_value, sizeof (listen_value));
/* Note that we DON'T want to actually detach from inferior_pid,
/* Note that we DON'T want to actually detach from inferior_ptid,
because that would allow it to run free. The original
debugger wants to retain control of the process. So, we
just reset inferior_pid to CHILD_PID, and then ensure that all
just reset inferior_ptid to CHILD_PID, and then ensure that all
breakpoints are really set in CHILD_PID.
*/
target_mourn_inferior ();

View File

@ -23,7 +23,7 @@
#include "frame.h"
#include "target.h"
#include "value.h"
#include "inferior.h" /* for inferior_pid */
#include "inferior.h" /* for inferior_ptid */
#include "regcache.h"
/* FIND_SAVED_REGISTER ()

View File

@ -849,15 +849,15 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
#ifdef TARGET_READ_PC
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
"TARGET_READ_PC(pid)",
XSTRING (TARGET_READ_PC (pid)));
"TARGET_READ_PC(ptid)",
XSTRING (TARGET_READ_PC (ptid)));
#endif
#if defined (TARGET_WRITE_PC) && GDB_MULTI_ARCH
/* Macro might contain `[{}]' when not multi-arch */
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
"TARGET_WRITE_PC(val, pid)",
XSTRING (TARGET_WRITE_PC (val, pid)));
"TARGET_WRITE_PC(val, ptid)",
XSTRING (TARGET_WRITE_PC (val, ptid)));
#endif
#ifdef TARGET_READ_FP
fprintf_unfiltered (file,
@ -2392,14 +2392,14 @@ set_gdbarch_ieee_float (struct gdbarch *gdbarch,
}
CORE_ADDR
gdbarch_read_pc (struct gdbarch *gdbarch, int pid)
gdbarch_read_pc (struct gdbarch *gdbarch, ptid_t ptid)
{
if (gdbarch->read_pc == 0)
internal_error (__FILE__, __LINE__,
"gdbarch: gdbarch_read_pc invalid");
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_read_pc called\n");
return gdbarch->read_pc (pid);
return gdbarch->read_pc (ptid);
}
void
@ -2410,14 +2410,14 @@ set_gdbarch_read_pc (struct gdbarch *gdbarch,
}
void
gdbarch_write_pc (struct gdbarch *gdbarch, CORE_ADDR val, int pid)
gdbarch_write_pc (struct gdbarch *gdbarch, CORE_ADDR val, ptid_t ptid)
{
if (gdbarch->write_pc == 0)
internal_error (__FILE__, __LINE__,
"gdbarch: gdbarch_write_pc invalid");
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_write_pc called\n");
gdbarch->write_pc (val, pid);
gdbarch->write_pc (val, ptid);
}
void

View File

@ -257,29 +257,29 @@ extern void set_gdbarch_ieee_float (struct gdbarch *gdbarch, int ieee_float);
/* Default (function) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (TARGET_READ_PC)
#define TARGET_READ_PC(pid) (generic_target_read_pc (pid))
#define TARGET_READ_PC(ptid) (generic_target_read_pc (ptid))
#endif
typedef CORE_ADDR (gdbarch_read_pc_ftype) (int pid);
extern CORE_ADDR gdbarch_read_pc (struct gdbarch *gdbarch, int pid);
typedef CORE_ADDR (gdbarch_read_pc_ftype) (ptid_t ptid);
extern CORE_ADDR gdbarch_read_pc (struct gdbarch *gdbarch, ptid_t ptid);
extern void set_gdbarch_read_pc (struct gdbarch *gdbarch, gdbarch_read_pc_ftype *read_pc);
#if GDB_MULTI_ARCH
#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (TARGET_READ_PC)
#define TARGET_READ_PC(pid) (gdbarch_read_pc (current_gdbarch, pid))
#define TARGET_READ_PC(ptid) (gdbarch_read_pc (current_gdbarch, ptid))
#endif
#endif
/* Default (function) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (TARGET_WRITE_PC)
#define TARGET_WRITE_PC(val, pid) (generic_target_write_pc (val, pid))
#define TARGET_WRITE_PC(val, ptid) (generic_target_write_pc (val, ptid))
#endif
typedef void (gdbarch_write_pc_ftype) (CORE_ADDR val, int pid);
extern void gdbarch_write_pc (struct gdbarch *gdbarch, CORE_ADDR val, int pid);
typedef void (gdbarch_write_pc_ftype) (CORE_ADDR val, ptid_t ptid);
extern void gdbarch_write_pc (struct gdbarch *gdbarch, CORE_ADDR val, ptid_t ptid);
extern void set_gdbarch_write_pc (struct gdbarch *gdbarch, gdbarch_write_pc_ftype *write_pc);
#if GDB_MULTI_ARCH
#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (TARGET_WRITE_PC)
#define TARGET_WRITE_PC(val, pid) (gdbarch_write_pc (current_gdbarch, val, pid))
#define TARGET_WRITE_PC(val, ptid) (gdbarch_write_pc (current_gdbarch, val, ptid))
#endif
#endif

View File

@ -376,8 +376,8 @@ v::TARGET_BFD_VMA_BIT:int:bfd_vma_bit::::8 * sizeof (void*):TARGET_ARCHITECTURE-
#
v::IEEE_FLOAT:int:ieee_float::::0:0::0:::
#
f::TARGET_READ_PC:CORE_ADDR:read_pc:int pid:pid::0:generic_target_read_pc::0
f::TARGET_WRITE_PC:void:write_pc:CORE_ADDR val, int pid:val, pid::0:generic_target_write_pc::0
f::TARGET_READ_PC:CORE_ADDR:read_pc:ptid_t ptid:ptid::0:generic_target_read_pc::0
f::TARGET_WRITE_PC:void:write_pc:CORE_ADDR val, ptid_t ptid:val, ptid::0:generic_target_write_pc::0
f::TARGET_READ_FP:CORE_ADDR:read_fp:void:::0:generic_target_read_fp::0
f::TARGET_WRITE_FP:void:write_fp:CORE_ADDR val:val::0:generic_target_write_fp::0
f::TARGET_READ_SP:CORE_ADDR:read_sp:void:::0:generic_target_read_sp::0

View File

@ -31,7 +31,7 @@
struct thread_info
{
struct thread_info *next;
int pid; /* "Actual process id";
ptid_t ptid; /* "Actual process id";
In fact, this may be overloaded with
kernel thread id, etc. */
int num; /* Convenient handle (GDB thread id) */
@ -73,29 +73,29 @@ extern void init_thread_list (void);
/* Add a thread to the thread list.
Note that add_thread now returns the handle of the new thread,
so that the caller may initialize the private thread data. */
extern struct thread_info *add_thread (int pid);
extern struct thread_info *add_thread (ptid_t ptid);
/* Delete an existing thread list entry. */
extern void delete_thread (int);
extern void delete_thread (ptid_t);
/* Translate the integer thread id (GDB's homegrown id, not the system's)
into a "pid" (which may be overloaded with extra thread information). */
extern int thread_id_to_pid (int);
extern ptid_t thread_id_to_pid (int);
/* Translate a 'pid' (which may be overloaded with extra thread information)
into the integer thread id (GDB's homegrown id, not the system's). */
extern int pid_to_thread_id (int pid);
extern int pid_to_thread_id (ptid_t ptid);
/* Boolean test for an already-known pid (which may be overloaded with
extra thread information). */
extern int in_thread_list (int pid);
extern int in_thread_list (ptid_t ptid);
/* Boolean test for an already-known thread id (GDB's homegrown id,
not the system's). */
extern int valid_thread_id (int thread);
/* Search function to lookup a thread by 'pid'. */
extern struct thread_info *find_thread_pid (int pid);
extern struct thread_info *find_thread_pid (ptid_t ptid);
/* Iterator function to call a user-provided callback function
once for each known thread. */
@ -103,7 +103,7 @@ typedef int (*thread_callback_func) (struct thread_info *, void *);
extern struct thread_info *iterate_over_threads (thread_callback_func, void *);
/* infrun context switch: save the debugger state for the given thread. */
extern void save_infrun_state (int pid,
extern void save_infrun_state (ptid_t ptid,
CORE_ADDR prev_pc,
CORE_ADDR prev_func_start,
char *prev_func_name,
@ -121,7 +121,7 @@ extern void save_infrun_state (int pid,
/* infrun context switch: load the debugger state previously saved
for the given thread. */
extern void load_infrun_state (int pid,
extern void load_infrun_state (ptid_t ptid,
CORE_ADDR *prev_pc,
CORE_ADDR *prev_func_start,
char **prev_func_name,

View File

@ -1064,7 +1064,7 @@ inf_validate_procs (struct inf *inf)
(last ? last->next : inf->threads) = thread;
last = thread;
proc_debug (thread, "new thread: %d", threads[i]);
add_thread (thread->tid); /* Tell GDB's generic thread code. */
add_thread (pid_to_ptid (thread->tid)); /* Tell GDB's generic thread code. */
}
}
@ -1408,8 +1408,8 @@ struct inf *current_inferior = 0;
struct inf *waiting_inf;
/* Wait for something to happen in the inferior, returning what in STATUS. */
static int
gnu_wait (int tid, struct target_waitstatus *status)
static ptid_t
gnu_wait (ptid_t tid, struct target_waitstatus *status)
{
struct msg
{
@ -1440,7 +1440,7 @@ gnu_wait (int tid, struct target_waitstatus *status)
waiting_inf = inf;
inf_debug (inf, "waiting for: %d", tid);
inf_debug (inf, "waiting for: %d", PIDGET (tid));
rewait:
if (proc_wait_pid != inf->pid && !inf->no_wait)
@ -1576,20 +1576,20 @@ rewait:
thread = inf->wait.thread;
if (thread)
tid = thread->tid;
tid = pid_to_ptid (thread->tid);
else
thread = inf_tid_to_thread (inf, tid);
thread = inf_tid_to_thread (inf, PIDGET (tid));
if (!thread || thread->port == MACH_PORT_NULL)
{
/* TID is dead; try and find a new thread. */
if (inf_update_procs (inf) && inf->threads)
tid = inf->threads->tid; /* The first available thread. */
tid = pid_to_ptid (inf->threads->tid); /* The first available thread. */
else
tid = inferior_pid; /* let wait_for_inferior handle exit case */
tid = inferior_ptid; /* let wait_for_inferior handle exit case */
}
if (thread && tid >= 0 && status->kind != TARGET_WAITKIND_SPURIOUS
if (thread && PIDGET (tid) >= 0 && status->kind != TARGET_WAITKIND_SPURIOUS
&& inf->pause_sc == 0 && thread->pause_sc == 0)
/* If something actually happened to THREAD, make sure we
suspend it. */
@ -1598,7 +1598,7 @@ rewait:
inf_update_suspends (inf);
}
inf_debug (inf, "returning tid = %d, status = %s (%d)", tid,
inf_debug (inf, "returning tid = %d, status = %s (%d)", PIDGET (tid),
status->kind == TARGET_WAITKIND_EXITED ? "EXITED"
: status->kind == TARGET_WAITKIND_STOPPED ? "STOPPED"
: status->kind == TARGET_WAITKIND_SIGNALLED ? "SIGNALLED"
@ -1925,12 +1925,12 @@ port_msgs_queued (mach_port_t port)
in multiple events returned by wait).
*/
static void
gnu_resume (int tid, int step, enum target_signal sig)
gnu_resume (ptid_t tid, int step, enum target_signal sig)
{
struct proc *step_thread = 0;
struct inf *inf = current_inferior;
inf_debug (inf, "tid = %d, step = %d, sig = %d", tid, step, sig);
inf_debug (inf, "tid = %d, step = %d, sig = %d", PIDGET (tid), step, sig);
inf_validate_procinfo (inf);
@ -1958,17 +1958,17 @@ gnu_resume (int tid, int step, enum target_signal sig)
inf_update_procs (inf);
if (tid < 0)
if (PIDGET (tid) < 0)
/* Allow all threads to run, except perhaps single-stepping one. */
{
inf_debug (inf, "running all threads; tid = %d", inferior_pid);
tid = inferior_pid; /* What to step. */
inf_debug (inf, "running all threads; tid = %d", PIDGET (inferior_ptid));
tid = inferior_ptid; /* What to step. */
inf_set_threads_resume_sc (inf, 0, 1);
}
else
/* Just allow a single thread to run. */
{
struct proc *thread = inf_tid_to_thread (inf, tid);
struct proc *thread = inf_tid_to_thread (inf, PIDGET (tid));
if (!thread)
error ("Can't run single thread id %d: no such thread!");
inf_debug (inf, "running one thread: %d/%d", inf->pid, thread->tid);
@ -1977,9 +1977,9 @@ gnu_resume (int tid, int step, enum target_signal sig)
if (step)
{
step_thread = inf_tid_to_thread (inf, tid);
step_thread = inf_tid_to_thread (inf, PIDGET (tid));
if (!step_thread)
warning ("Can't step thread id %d: no such thread.", tid);
warning ("Can't step thread id %d: no such thread.", PIDGET (tid));
else
inf_debug (inf, "stepping thread: %d/%d", inf->pid, step_thread->tid);
}
@ -2066,7 +2066,7 @@ gnu_create_inferior (char *exec_file, char *allargs, char **env)
/* Now let the child run again, knowing that it will stop immediately
because of the ptrace. */
inf_resume (inf);
inferior_pid = inf_pick_first_thread ();
inferior_ptid = pid_to_ptid (inf_pick_first_thread ());
startup_inferior (inf->pending_execs);
}
@ -2137,7 +2137,7 @@ gnu_attach (char *args, int from_tty)
inf_attach (inf, pid);
inf_update_procs (inf);
inferior_pid = inf_pick_first_thread ();
inferior_ptid = pid_to_ptid (inf_pick_first_thread ());
attach_flag = 1;
push_target (&gnu_ops);
@ -2182,7 +2182,7 @@ gnu_detach (char *args, int from_tty)
inf_detach (current_inferior);
inferior_pid = 0;
inferior_ptid = null_ptid;
unpush_target (&gnu_ops); /* Pop out of handling an inferior */
}
@ -2230,10 +2230,10 @@ gnu_pid_to_exec_file (void)
static int
gnu_thread_alive (int tid)
gnu_thread_alive (ptid_t tid)
{
inf_update_procs (current_inferior);
return !!inf_tid_to_thread (current_inferior, tid);
return !!inf_tid_to_thread (current_inferior, PIDGET (tid));
}
@ -2481,9 +2481,10 @@ proc_string (struct proc *proc)
}
static char *
gnu_pid_to_str (int tid)
gnu_pid_to_str (ptid_t ptid)
{
struct inf *inf = current_inferior;
int tid = PIDGET (ptid);
struct proc *thread = inf_tid_to_thread (inf, tid);
if (thread)
@ -2653,7 +2654,7 @@ static struct proc *
cur_thread (void)
{
struct inf *inf = cur_inf ();
struct proc *thread = inf_tid_to_thread (inf, inferior_pid);
struct proc *thread = inf_tid_to_thread (inf, PIDGET (inferior_ptid));
if (!thread)
error ("No current thread.");
return thread;

View File

@ -164,8 +164,10 @@ static void go32_open (char *name, int from_tty);
static void go32_close (int quitting);
static void go32_attach (char *args, int from_tty);
static void go32_detach (char *args, int from_tty);
static void go32_resume (int pid, int step, enum target_signal siggnal);
static int go32_wait (int pid, struct target_waitstatus *status);
static void go32_resume (ptid_t ptid, int step,
enum target_signal siggnal);
static ptid_t go32_wait (ptid_t ptid,
struct target_waitstatus *status);
static void go32_fetch_registers (int regno);
static void store_register (int regno);
static void go32_store_registers (int regno);
@ -315,7 +317,7 @@ static int resume_is_step;
static int resume_signal = -1;
static void
go32_resume (int pid, int step, enum target_signal siggnal)
go32_resume (ptid_t ptid, int step, enum target_signal siggnal)
{
int i;
@ -339,7 +341,7 @@ go32_resume (int pid, int step, enum target_signal siggnal)
static char child_cwd[FILENAME_MAX];
static int
go32_wait (int pid, struct target_waitstatus *status)
go32_wait (ptid_t ptid, struct target_waitstatus *status)
{
int i;
unsigned char saved_opcode;
@ -558,7 +560,7 @@ go32_stop (void)
{
normal_stop ();
cleanup_client ();
inferior_pid = 0;
inferior_ptid = null_ptid;
prog_has_started = 0;
}
@ -632,7 +634,7 @@ go32_create_inferior (char *exec_file, char *args, char **env)
save_npx ();
#endif
inferior_pid = SOME_PID;
inferior_ptid = pid_to_ptid (SOME_PID);
push_target (&go32_ops);
clear_proceed_status ();
insert_breakpoints ();

View File

@ -586,13 +586,13 @@ h8500_write_sp (CORE_ADDR v)
}
CORE_ADDR
h8500_read_pc (int pid)
h8500_read_pc (ptid_t ptid)
{
return read_register (PC_REGNUM);
}
void
h8500_write_pc (CORE_ADDR v, int pid)
h8500_write_pc (CORE_ADDR v, ptid_t ptid)
{
write_register (PC_REGNUM, v);
}

View File

@ -74,8 +74,8 @@ _initialize_hp300ux_nat (void)
#define INFERIOR_AR0(u) \
((ptrace \
(PT_RUAREA, inferior_pid, \
(PTRACE_ARG3_TYPE) ((char *) &u.u_ar0 - (char *) &u), 0, 0)) \
(PT_RUAREA, PIDGET (inferior_ptid), \
(PTRACE_ARG3_TYPE) ((char *) &u.u_ar0 - (char *) &u), 0, 0)) \
- kernel_u_addr)
static void
@ -92,8 +92,8 @@ fetch_inferior_register (register int regno, register unsigned int regaddr)
ps_val;
int regval;
ps_val.i = (ptrace (PT_RUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
0, 0));
ps_val.i = (ptrace (PT_RUAREA, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, 0, 0));
regval = ps_val.s[0];
supply_register (regno, (char *) &regval);
}
@ -105,7 +105,7 @@ fetch_inferior_register (register int regno, register unsigned int regaddr)
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
{
*(int *) &buf[i] = ptrace (PT_RUAREA, inferior_pid,
*(int *) &buf[i] = ptrace (PT_RUAREA, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, 0, 0);
regaddr += sizeof (int);
}
@ -118,7 +118,8 @@ static void
store_inferior_register_1 (int regno, unsigned int regaddr, int val)
{
errno = 0;
ptrace (PT_WUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, val, 0);
ptrace (PT_WUAREA, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr,
val, 0);
#if 0
/* HP-UX randomly sets errno to non-zero for regno == 25.
However, the value is correctly written, so ignore errno. */
@ -146,8 +147,8 @@ store_inferior_register (register int regno, register unsigned int regaddr)
}
ps_val;
ps_val.i = (ptrace (PT_RUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
0, 0));
ps_val.i = (ptrace (PT_RUAREA, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, 0, 0));
ps_val.s[0] = (read_register (regno));
store_inferior_register_1 (regno, regaddr, ps_val.i);
}

View File

@ -1397,7 +1397,7 @@ push_dummy_frame (struct inferior_status *inf_status)
We also need a number of horrid hacks to deal with lossage in the
PC queue registers (apparently they're not valid when the in syscall
bit is set). */
pc = target_read_pc (inferior_pid);
pc = target_read_pc (inferior_ptid);
int_buffer = read_register (FLAGS_REGNUM);
if (int_buffer & 0x2)
{
@ -1631,7 +1631,7 @@ restore_pc_queue (struct frame_saved_regs *fsr)
any other choice? Is there *any* way to do this stuff with
ptrace() or some equivalent?). */
resume (1, 0);
target_wait (inferior_pid, &w);
target_wait (inferior_ptid, &w);
if (w.kind == TARGET_WAITKIND_SIGNALLED)
{
@ -2076,9 +2076,9 @@ hppa_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
such that it points to the PC value written immediately above
(ie the call dummy). */
resume (1, 0);
target_wait (inferior_pid, &w);
target_wait (inferior_ptid, &w);
resume (1, 0);
target_wait (inferior_pid, &w);
target_wait (inferior_ptid, &w);
/* Restore the two instructions at the old PC locations. */
*((int *) buf) = inst1;
@ -2162,7 +2162,7 @@ hppa_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
stub rather than the export stub or real function for lazy binding
to work correctly
/* If we are using the gcc PLT call routine, then we need to
If we are using the gcc PLT call routine, then we need to
get the import stub for the target function. */
if (using_gcc_plt_call && som_solib_get_got_by_pc (fun))
{
@ -2370,7 +2370,7 @@ hppa_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
if (flags & 2)
return pc;
#ifndef GDB_TARGET_IS_PA_ELF
else if (som_solib_get_got_by_pc (target_read_pc (inferior_pid)))
else if (som_solib_get_got_by_pc (target_read_pc (inferior_ptid)))
return pc;
#endif
else
@ -2404,26 +2404,26 @@ target_read_fp (int pid)
bits. */
CORE_ADDR
target_read_pc (int pid)
target_read_pc (ptid_t ptid)
{
int flags = read_register_pid (FLAGS_REGNUM, pid);
int flags = read_register_pid (FLAGS_REGNUM, ptid);
/* The following test does not belong here. It is OS-specific, and belongs
in native code. */
/* Test SS_INSYSCALL */
if (flags & 2)
return read_register_pid (31, pid) & ~0x3;
return read_register_pid (31, ptid) & ~0x3;
return read_register_pid (PC_REGNUM, pid) & ~0x3;
return read_register_pid (PC_REGNUM, ptid) & ~0x3;
}
/* Write out the PC. If currently in a syscall, then also write the new
PC value into %r31. */
void
target_write_pc (CORE_ADDR v, int pid)
target_write_pc (CORE_ADDR v, ptid_t ptid)
{
int flags = read_register_pid (FLAGS_REGNUM, pid);
int flags = read_register_pid (FLAGS_REGNUM, ptid);
/* The following test does not belong here. It is OS-specific, and belongs
in native code. */
@ -2431,10 +2431,10 @@ target_write_pc (CORE_ADDR v, int pid)
privilege bits set correctly. */
/* Test SS_INSYSCALL */
if (flags & 2)
write_register_pid (31, v | 0x3, pid);
write_register_pid (31, v | 0x3, ptid);
write_register_pid (PC_REGNUM, v, pid);
write_register_pid (NPC_REGNUM, v + 4, pid);
write_register_pid (PC_REGNUM, v, ptid);
write_register_pid (NPC_REGNUM, v + 4, ptid);
}
/* return the alignment of a type in bytes. Structures have the maximum
@ -2645,7 +2645,7 @@ pa_register_look_aside (char *raw_regs, int regnum, long *raw_val)
for (i = start; i < 2; i++)
{
errno = 0;
raw_val[i] = call_ptrace (PT_RUREGS, inferior_pid,
raw_val[i] = call_ptrace (PT_RUREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, 0);
if (errno != 0)
{
@ -4026,7 +4026,7 @@ hppa_frame_find_saved_regs (struct frame_info *frame_info,
}
}
/* Quit if we hit any kind of branch the previous iteration.
/* Quit if we hit any kind of branch the previous iteration. */
if (final_iteration)
break;
@ -4108,7 +4108,7 @@ setup_d_pid_in_inferior (void)
}
anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
store_unsigned_integer (buf, 4, inferior_pid); /* FIXME 32x64? */
store_unsigned_integer (buf, 4, PIDGET (inferior_ptid)); /* FIXME 32x64? */
if (target_write_memory (anaddr, buf, 4)) /* FIXME 32x64? */
{
warning ("Unable to write __d_pid");
@ -4378,7 +4378,7 @@ child_enable_exception_callback (enum exception_event_kind kind, int enable)
if (enable)
{
/* Ensure that __d_pid is set up correctly -- end.c code checks this. :-( */
if (inferior_pid > 0)
if (PIDGET (inferior_ptid) > 0)
{
if (setup_d_pid_in_inferior ())
return (struct symtab_and_line *) -1;
@ -4601,7 +4601,7 @@ hppa_prepare_to_proceed (void)
pid_t old_thread;
pid_t current_thread;
old_thread = hppa_switched_threads (inferior_pid);
old_thread = hppa_switched_threads (PIDGET (inferior_ptid));
if (old_thread != 0)
{
/* Switched over from "old_thread". Try to do
@ -4612,8 +4612,8 @@ hppa_prepare_to_proceed (void)
/* Yuk, shouldn't use global to specify current
thread. But that's how gdb does it. */
current_thread = inferior_pid;
inferior_pid = old_thread;
current_thread = PIDGET (inferior_ptid);
inferior_ptid = pid_to_ptid (old_thread);
new_pc = read_pc ();
if (new_pc != old_pc /* If at same pc, no need */
@ -4625,14 +4625,14 @@ hppa_prepare_to_proceed (void)
registers_changed ();
#if 0
printf ("---> PREPARE_TO_PROCEED (was %d, now %d)!\n",
current_thread, inferior_pid);
current_thread, PIDGET (inferior_ptid));
#endif
return 1;
}
/* Otherwise switch back to the user-chosen thread. */
inferior_pid = current_thread;
inferior_ptid = pid_to_ptid (current_thread);
new_pc = read_pc (); /* Re-prime register cache */
}

View File

@ -44,7 +44,7 @@
/* U_REGS_OFFSET is the offset of the registers within the u area. */
#if !defined (U_REGS_OFFSET)
#define U_REGS_OFFSET \
ptrace (PT_READ_U, inferior_pid, \
ptrace (PT_READ_U, PIDGET (inferior_ptid), \
(PTRACE_ARG3_TYPE) (offsetof (struct user, u_ar0)), 0) \
- KERNEL_U_ADDR
#endif
@ -67,7 +67,7 @@ fetch_register (int regno)
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
{
errno = 0;
*(int *) &buf[i] = ptrace (PT_RUREGS, inferior_pid,
*(int *) &buf[i] = ptrace (PT_RUREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, 0);
regaddr += sizeof (int);
if (errno != 0)
@ -119,7 +119,7 @@ store_inferior_registers (int regno)
if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM)
{
scratch = *(int *) &registers[REGISTER_BYTE (regno)] | 0x3;
ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
ptrace (PT_WUREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr,
scratch);
if (errno != 0)
{
@ -133,7 +133,8 @@ store_inferior_registers (int regno)
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
{
errno = 0;
ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
ptrace (PT_WUREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr,
*(int *) &registers[REGISTER_BYTE (regno) + i]);
if (errno != 0)
{
@ -209,5 +210,5 @@ hppa_set_watchpoint (int addr, int len, int flag)
pt_args[1] <<= 12;
/* Do it. */
return ptrace (PT_PROT, inferior_pid, (PTRACE_ARG3_TYPE) pt_args, 0);
return ptrace (PT_PROT, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) pt_args, 0);
}

View File

@ -126,7 +126,8 @@ store_inferior_registers (int regno)
/* Set the priv level (stored in the low two bits of the PC. */
temp |= 0x3;
ttrace_write_reg_64 (inferior_pid, (CORE_ADDR)addr, (CORE_ADDR)&temp);
ttrace_write_reg_64 (PIDGET (inferior_ptid), (CORE_ADDR)addr,
(CORE_ADDR)&temp);
/* If we fail to write the PC, give a true error instead of
just a warning. */
@ -151,7 +152,8 @@ store_inferior_registers (int regno)
for (i = 0; i < len; i += sizeof (int))
{
errno = 0;
call_ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) addr + i,
call_ptrace (PT_WUREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr + i,
*(int *) &registers[REGISTER_BYTE (regno) + i]);
if (errno != 0)
{
@ -234,7 +236,7 @@ fetch_register (int regno)
/* Copy an int from the U area to buf. Fill the least
significant end if len != raw_size. */
* (int *) &buf[offset + i] =
call_ptrace (PT_RUREGS, inferior_pid,
call_ptrace (PT_RUREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr + i, 0);
if (errno != 0)
{
@ -297,14 +299,15 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
{
/* Need part of initial word -- fetch it. */
buffer[0] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr, 0);
}
if (count > 1) /* FIXME, avoid if even boundary */
{
buffer[count - 1]
= call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
inferior_pid,
PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) (addr
+ (count - 1) * sizeof (int)),
0);
@ -326,7 +329,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
errno = 0;
pt_request = (addr < text_end) ? PT_WIUSER : PT_WDUSER;
pt_status = call_ptrace (pt_request,
inferior_pid,
PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr,
buffer[i]);
@ -338,7 +341,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
errno = 0;
pt_request = (pt_request == PT_WIUSER) ? PT_WDUSER : PT_WIUSER;
pt_status = call_ptrace (pt_request,
inferior_pid,
PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr,
buffer[i]);
@ -358,7 +361,8 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
{
errno = 0;
buffer[i] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr, 0);
if (errno)
{
xfree (buffer);
@ -389,7 +393,7 @@ child_post_follow_inferior_by_clone (void)
At this point, the clone has attached to the child. Because of
the SIGSTOP, we must now deliver a SIGCONT to the child, or it
won't behave properly. */
status = kill (inferior_pid, SIGCONT);
status = kill (PIDGET (inferior_ptid), SIGCONT);
}
@ -433,10 +437,11 @@ child_post_follow_vfork (int parent_pid, int followed_parent, int child_pid,
/* Format a process id, given PID. Be sure to terminate
this with a null--it's going to be printed via a "%s". */
char *
child_pid_to_str (pid_t pid)
child_pid_to_str (ptid_t ptid)
{
/* Static because address returned */
static char buf[30];
pid_t pid = PIDGET (ptid);
/* Extra NULLs for paranoia's sake */
sprintf (buf, "process %d\0\0\0\0", pid);
@ -450,10 +455,13 @@ child_pid_to_str (pid_t pid)
Note: This is a core-gdb tid, not the actual system tid.
See infttrace.c for details. */
char *
hppa_tid_to_str (pid_t tid)
hppa_tid_to_str (ptid_t ptid)
{
/* Static because address returned */
static char buf[30];
/* This seems strange, but when I did the ptid conversion, it looked
as though a pid was always being passed. - Kevin Buettner */
pid_t tid = PIDGET (ptid);
/* Extra NULLs for paranoia's sake */
sprintf (buf, "system thread %d\0\0\0\0", tid);
@ -626,7 +634,7 @@ hppa_range_profitable_for_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len)
}
char *
hppa_pid_or_tid_to_str (pid_t id)
hppa_pid_or_tid_to_str (ptid_t id)
{
/* In the ptrace world, there are only processes. */
return child_pid_to_str (id);
@ -814,9 +822,9 @@ child_acknowledge_created_inferior (int pid)
}
void
child_post_startup_inferior (int pid)
child_post_startup_inferior (ptid_t ptid)
{
require_notification_of_events (pid);
require_notification_of_events (PIDGET (ptid));
}
void
@ -1040,7 +1048,7 @@ child_pid_to_exec_file (int pid)
char four_chars[4];
int name_index;
int i;
int saved_inferior_pid;
ptid_t saved_inferior_ptid;
boolean done;
#ifdef PT_GET_PROCESS_PATHNAME
@ -1062,19 +1070,19 @@ child_pid_to_exec_file (int pid)
name_index = 0;
done = 0;
/* On the chance that pid != inferior_pid, set inferior_pid
to pid, so that (grrrr!) implicit uses of inferior_pid get
/* On the chance that pid != inferior_ptid, set inferior_ptid
to pid, so that (grrrr!) implicit uses of inferior_ptid get
the right id. */
saved_inferior_pid = inferior_pid;
inferior_pid = pid;
saved_inferior_ptid = inferior_ptid;
inferior_ptid = pid_to_ptid (pid);
/* Try to grab a null-terminated string. */
while (!done)
{
if (target_read_memory (top_of_stack, four_chars, 4) != 0)
{
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return NULL;
}
for (i = 0; i < 4; i++)
@ -1089,11 +1097,11 @@ child_pid_to_exec_file (int pid)
if (exec_file_buffer[0] == '\0')
{
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return NULL;
}
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return exec_file_buffer;
}
@ -1124,7 +1132,7 @@ pre_fork_inferior (void)
return "TRUE". */
int
child_thread_alive (int pid)
child_thread_alive (ptid_t ptid)
{
return 1;
}

View File

@ -57,16 +57,17 @@ struct string_map
static int hpux_thread_active = 0;
static int main_pid; /* Real process ID */
static ptid_t main_ptid; /* Real process ID */
static CORE_ADDR P_cma__g_known_threads;
static CORE_ADDR P_cma__g_current_thread;
static struct cleanup *save_inferior_pid (void);
static struct cleanup *save_inferior_ptid (void);
static void restore_inferior_pid (int pid);
static void restore_inferior_ptid (ptid_t pid);
static void hpux_thread_resume (int pid, int step, enum target_signal signo);
static void hpux_thread_resume (ptid_t ptid, int step,
enum target_signal signo);
static void init_hpux_thread_ops (void);
@ -76,40 +77,40 @@ static struct target_ops hpux_thread_ops;
LOCAL FUNCTION
save_inferior_pid - Save inferior_pid on the cleanup list
restore_inferior_pid - Restore inferior_pid from the cleanup list
save_inferior_ptid - Save inferior_ptid on the cleanup list
restore_inferior_ptid - Restore inferior_ptid from the cleanup list
SYNOPSIS
struct cleanup *save_inferior_pid ()
void restore_inferior_pid (int pid)
struct cleanup *save_inferior_ptid ()
void restore_inferior_ptid (int pid)
DESCRIPTION
These two functions act in unison to restore inferior_pid in
These two functions act in unison to restore inferior_ptid in
case of an error.
NOTES
inferior_pid is a global variable that needs to be changed by many of
inferior_ptid is a global variable that needs to be changed by many of
these routines before calling functions in procfs.c. In order to
guarantee that inferior_pid gets restored (in case of errors), you
need to call save_inferior_pid before changing it. At the end of the
guarantee that inferior_ptid gets restored (in case of errors), you
need to call save_inferior_ptid before changing it. At the end of the
function, you should invoke do_cleanups to restore it.
*/
static struct cleanup *
save_inferior_pid (void)
save_inferior_ptid (void)
{
return make_cleanup (restore_inferior_pid, inferior_pid);
return make_cleanup (restore_inferior_ptid, inferior_ptid);
}
static void
restore_inferior_pid (int pid)
restore_inferior_ptid (ptid_t ptid)
{
inferior_pid = pid;
inferior_ptid = ptid;
}
static int find_active_thread (void);
@ -133,7 +134,8 @@ find_active_thread (void)
read_memory (tcb_ptr, (char *) &tcb, sizeof tcb);
return (cma_thread_get_unique (&tcb.prolog.client_thread) << 16) | main_pid;
return (cma_thread_get_unique (&tcb.prolog.client_thread) << 16)
| PIDGET (main_ptid);
}
static cma__t_int_tcb *find_tcb (int thread);
@ -214,13 +216,14 @@ hpux_thread_detach (char *args, int from_tty)
for procfs. */
static void
hpux_thread_resume (int pid, int step, enum target_signal signo)
hpux_thread_resume (ptid_t ptid, int step, enum target_signal signo)
{
struct cleanup *old_chain;
old_chain = save_inferior_pid ();
old_chain = save_inferior_ptid ();
pid = inferior_pid = main_pid;
ptid = main_ptid;
inferior_ptid = main_ptid;
#if 0
if (pid != -1)
@ -231,7 +234,7 @@ hpux_thread_resume (int pid, int step, enum target_signal signo)
}
#endif
child_ops.to_resume (pid, step, signo);
child_ops.to_resume (ptid, step, signo);
cached_thread = 0;
cached_active_thread = 0;
@ -242,20 +245,20 @@ hpux_thread_resume (int pid, int step, enum target_signal signo)
/* Wait for any threads to stop. We may have to convert PID from a thread id
to a LWP id, and vice versa on the way out. */
static int
hpux_thread_wait (int pid, struct target_waitstatus *ourstatus)
static ptid_t
hpux_thread_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
int rtnval;
ptid_t rtnval;
struct cleanup *old_chain;
old_chain = save_inferior_pid ();
old_chain = save_inferior_ptid ();
inferior_pid = main_pid;
inferior_ptid = main_ptid;
if (pid != -1)
pid = main_pid;
if (!ptid_equal (ptid, minus_one_ptid))
ptid = main_ptid;
rtnval = child_ops.to_wait (pid, ourstatus);
rtnval = child_ops.to_wait (ptid, ourstatus);
rtnval = find_active_thread ();
@ -298,11 +301,11 @@ hpux_thread_fetch_registers (int regno)
int i;
int first_regno, last_regno;
tcb_ptr = find_tcb (inferior_pid);
tcb_ptr = find_tcb (PIDGET (inferior_ptid));
old_chain = save_inferior_pid ();
old_chain = save_inferior_ptid ();
inferior_pid = main_pid;
inferior_ptid = main_ptid;
if (tcb_ptr->state == cma__c_state_running)
{
@ -360,11 +363,11 @@ hpux_thread_store_registers (int regno)
int i;
int first_regno, last_regno;
tcb_ptr = find_tcb (inferior_pid);
tcb_ptr = find_tcb (PIDGET (inferior_ptid));
old_chain = save_inferior_pid ();
old_chain = save_inferior_ptid ();
inferior_pid = main_pid;
inferior_ptid = main_ptid;
if (tcb_ptr->state == cma__c_state_running)
{
@ -441,9 +444,9 @@ hpux_thread_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,
int retval;
struct cleanup *old_chain;
old_chain = save_inferior_pid ();
old_chain = save_inferior_ptid ();
inferior_pid = main_pid;
inferior_ptid = main_ptid;
retval =
child_ops.to_xfer_memory (memaddr, myaddr, len, dowrite, attribs, target);
@ -468,9 +471,9 @@ hpux_thread_kill_inferior (void)
}
static void
hpux_thread_notice_signals (int pid)
hpux_thread_notice_signals (ptid_t ptid)
{
child_ops.to_notice_signals (pid);
child_ops.to_notice_signals (ptid);
}
/* Fork an inferior process, and start debugging it with /proc. */
@ -482,13 +485,13 @@ hpux_thread_create_inferior (char *exec_file, char *allargs, char **env)
if (hpux_thread_active)
{
main_pid = inferior_pid;
main_ptid = inferior_ptid;
push_target (&hpux_thread_ops);
inferior_pid = find_active_thread ();
inferior_ptid = find_active_thread ();
add_thread (inferior_pid);
add_thread (inferior_ptid);
}
}
@ -554,7 +557,7 @@ hpux_thread_can_run (void)
}
static int
hpux_thread_alive (int pid)
hpux_thread_alive (ptid_t ptid)
{
return 1;
}
@ -568,9 +571,10 @@ hpux_thread_stop (void)
/* Convert a pid to printable form. */
char *
hpux_pid_to_str (int pid)
hpux_pid_to_str (ptid_t ptid)
{
static char buf[100];
int pid = PIDGET (ptid);
sprintf (buf, "Thread %d", pid >> 16);

View File

@ -63,7 +63,7 @@ static void dummy_sse_values (void);
/* On Linux, threads are implemented as pseudo-processes, in which
case we may be tracing more than one process at a time. In that
case, inferior_pid will contain the main process ID and the
case, inferior_ptid will contain the main process ID and the
individual thread (process) ID mashed together. These macros are
used to separate them out. These definitions should be overridden
if thread support is included. */
@ -198,8 +198,8 @@ fetch_register (int regno)
}
/* Overload thread id onto process id */
if ((tid = TIDGET (inferior_pid)) == 0)
tid = inferior_pid; /* no thread id, just use process id */
if ((tid = TIDGET (inferior_ptid)) == 0)
tid = PIDGET (inferior_ptid); /* no thread id, just use process id */
offset = U_REGS_OFFSET;
@ -261,8 +261,8 @@ store_register (int regno)
}
/* Overload thread id onto process id */
if ((tid = TIDGET (inferior_pid)) == 0)
tid = inferior_pid; /* no thread id, just use process id */
if ((tid = TIDGET (inferior_ptid)) == 0)
tid = PIDGET (inferior_ptid); /* no thread id, just use process id */
offset = U_REGS_OFFSET;
@ -597,8 +597,8 @@ fetch_inferior_registers (int regno)
}
/* Linux LWP ID's are process ID's. */
if ((tid = TIDGET (inferior_pid)) == 0)
tid = inferior_pid; /* Not a threaded program. */
if ((tid = TIDGET (inferior_ptid)) == 0)
tid = PIDGET (inferior_ptid); /* Not a threaded program. */
/* Use the PTRACE_GETFPXREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
@ -663,8 +663,8 @@ store_inferior_registers (int regno)
}
/* Linux LWP ID's are process ID's. */
if ((tid = TIDGET (inferior_pid)) == 0)
tid = inferior_pid; /* Not a threaded program. */
if ((tid = TIDGET (inferior_ptid)) == 0)
tid = PIDGET (inferior_ptid); /* Not a threaded program. */
/* Use the PTRACE_SETFPXREGS requests whenever possible, since it
transfers more registers in one system call. But remember that
@ -710,7 +710,7 @@ i386_linux_dr_get (int regnum)
/* FIXME: kettenis/2001-01-29: It's not clear what we should do with
multi-threaded processes here. For now, pretend there is just
one thread. */
tid = PIDGET (inferior_pid);
tid = PIDGET (inferior_ptid);
/* FIXME: kettenis/2001-03-27: Calling perror_with_name if the
ptrace call fails breaks debugging remote targets. The correct
@ -738,7 +738,7 @@ i386_linux_dr_set (int regnum, unsigned long value)
/* FIXME: kettenis/2001-01-29: It's not clear what we should do with
multi-threaded processes here. For now, pretend there is just
one thread. */
tid = PIDGET (inferior_pid);
tid = PIDGET (inferior_ptid);
errno = 0;
ptrace (PT_WRITE_U, tid,
@ -879,19 +879,21 @@ static const unsigned char linux_syscall[] = { 0xcd, 0x80 };
If SIGNAL is nonzero, give it that signal. */
void
child_resume (int pid, int step, enum target_signal signal)
child_resume (ptid_t ptid, int step, enum target_signal signal)
{
int pid = PIDGET (ptid);
int request = PTRACE_CONT;
if (pid == -1)
/* Resume all threads. */
/* I think this only gets used in the non-threaded case, where "resume
all threads" and "resume inferior_pid" are the same. */
pid = inferior_pid;
all threads" and "resume inferior_ptid" are the same. */
pid = PIDGET (inferior_ptid);
if (step)
{
CORE_ADDR pc = read_pc_pid (pid);
CORE_ADDR pc = read_pc_pid (pid_to_ptid (pid));
unsigned char buf[LINUX_SYSCALL_LEN];
request = PTRACE_SINGLESTEP;
@ -908,7 +910,8 @@ child_resume (int pid, int step, enum target_signal signal)
if (read_memory_nobpt (pc, (char *) buf, LINUX_SYSCALL_LEN) == 0
&& memcmp (buf, linux_syscall, LINUX_SYSCALL_LEN) == 0)
{
int syscall = read_register_pid (LINUX_SYSCALL_REGNUM, pid);
int syscall = read_register_pid (LINUX_SYSCALL_REGNUM,
pid_to_ptid (pid));
/* Then check the system call number. */
if (syscall == SYS_sigreturn || syscall == SYS_rt_sigreturn)

View File

@ -190,12 +190,13 @@ i386_float_info (void)
struct env387 fps_fixed;
int i;
if (inferior_pid)
if (! ptid_equal (inferior_ptid, null_ptid))
{
char buf[10];
unsigned short status;
ptrace (PT_READ_FPR, inferior_pid, buf, offsetof (struct env387, status));
ptrace (PT_READ_FPR, PIDGET (inferior_ptid), buf,
offsetof (struct env387, status));
memcpy (&status, buf, sizeof (status));
fpsaved = status;
}
@ -211,13 +212,13 @@ i386_float_info (void)
return;
}
if (inferior_pid)
if (! ptid_equal (inferior_ptid, null_ptid))
{
int offset;
for (offset = 0; offset < sizeof (fps); offset += 10)
{
char buf[10];
ptrace (PT_READ_FPR, inferior_pid, buf, offset);
ptrace (PT_READ_FPR, PIDGET (inferior_ptid), buf, offset);
memcpy ((char *) &fps.control + offset, buf,
MIN (10, sizeof (fps) - offset));
}
@ -234,10 +235,10 @@ fetch_register (int regno)
{
char buf[MAX_REGISTER_RAW_SIZE];
if (regno < FP0_REGNUM)
*(int *) buf = ptrace (PT_READ_GPR, inferior_pid,
*(int *) buf = ptrace (PT_READ_GPR, PIDGET (inferior_ptid),
PT_REG (regmap[regno]), 0, 0);
else
ptrace (PT_READ_FPR, inferior_pid, buf,
ptrace (PT_READ_FPR, PIDGET (inferior_ptid), buf,
(regno - FP0_REGNUM) * 10 + offsetof (struct env387, regs));
supply_register (regno, buf);
}
@ -259,10 +260,11 @@ store_register (int regno)
char buf[80];
errno = 0;
if (regno < FP0_REGNUM)
ptrace (PT_WRITE_GPR, inferior_pid, PT_REG (regmap[regno]),
ptrace (PT_WRITE_GPR, PIDGET (inferior_ptid), PT_REG (regmap[regno]),
*(int *) &registers[REGISTER_BYTE (regno)], 0);
else
ptrace (PT_WRITE_FPR, inferior_pid, &registers[REGISTER_BYTE (regno)],
ptrace (PT_WRITE_FPR, PIDGET (inferior_ptid),
&registers[REGISTER_BYTE (regno)],
(regno - FP0_REGNUM) * 10 + offsetof (struct env387, regs));
if (errno != 0)

View File

@ -35,7 +35,8 @@ fetch_inferior_registers (int regno)
{
struct reg inferior_registers;
ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) & inferior_registers, 0);
ptrace (PT_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers, 0);
memcpy (&registers[REGISTER_BYTE (0)], &inferior_registers, 4 * NUM_REGS);
registers_fetched ();
}
@ -46,7 +47,8 @@ store_inferior_registers (int regno)
struct reg inferior_registers;
memcpy (&inferior_registers, &registers[REGISTER_BYTE (0)], 4 * NUM_REGS);
ptrace (PT_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) & inferior_registers, 0);
ptrace (PT_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers, 0);
}
struct md_core
@ -245,10 +247,9 @@ i386_float_info (void)
unsigned int rounded_size;
/*extern int corechan; */
int skip;
extern int inferior_pid;
uaddr = (char *) &U_FPSTATE (u) - (char *) &u;
if (inferior_pid)
if (! ptid_equal (inferior_ptid, null_ptid))
{
int *ip;
@ -260,7 +261,8 @@ i386_float_info (void)
ip = (int *) buf;
for (i = 0; i < rounded_size; i++)
{
*ip++ = ptrace (PT_READ_U, inferior_pid, (caddr_t) rounded_addr, 0);
*ip++ = ptrace (PT_READ_U, PIDGET (inferior_ptid),
(caddr_t) rounded_addr, 0);
rounded_addr += sizeof (int);
}
}

View File

@ -166,7 +166,8 @@ fetch_inferior_registers (int regno)
{
gregset_t gregs;
if (ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &gregs, 0) == -1)
perror_with_name ("Couldn't get registers");
supply_gregset (&gregs);
@ -175,7 +176,7 @@ fetch_inferior_registers (int regno)
{
fpregset_t fpregs;
if (ptrace (PT_GETFPREGS, inferior_pid,
if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
perror_with_name ("Couldn't get floating point status");
@ -191,25 +192,26 @@ store_inferior_registers (int regno)
{
gregset_t gregs;
if (ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &gregs, 0) == -1)
perror_with_name ("Couldn't get registers");
fill_gregset (&gregs, regno);
if (ptrace (PT_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
perror_with_name ("Couldn't write registers");
if (regno == -1 || regno >= FP0_REGNUM)
{
fpregset_t fpregs;
if (ptrace (PT_GETFPREGS, inferior_pid,
if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
perror_with_name ("Couldn't get floating point status");
fill_fpregset (&fpregs, regno);
if (ptrace (PT_SETFPREGS, inferior_pid,
if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
perror_with_name ("Couldn't write floating point status");
}
@ -231,7 +233,8 @@ i386bsd_dr_set (int regnum, unsigned int value)
{
struct dbreg dbregs;
if (ptrace (PT_GETDBREGS, inferior_pid, (PTRACE_ARG3_TYPE) &dbregs, 0) == -1)
if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &dbregs, 0) == -1)
perror_with_name ("Couldn't get debug registers");
/* For some mysterious reason, some of the reserved bits in the
@ -241,7 +244,8 @@ i386bsd_dr_set (int regnum, unsigned int value)
DBREG_DRX ((&dbregs), regnum) = value;
if (ptrace (PT_SETDBREGS, inferior_pid, (PTRACE_ARG3_TYPE) &dbregs, 0) == -1)
if (ptrace (PT_SETDBREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &dbregs, 0) == -1)
perror_with_name ("Couldn't write debug registers");
}
@ -277,7 +281,8 @@ i386bsd_dr_get_status (void)
way to fix this is to add the hardware breakpoint and watchpoint
stuff to the target vectore. For now, just return zero if the
ptrace call fails. */
if (ptrace (PT_GETDBREGS, inferior_pid, (PTRACE_ARG3_TYPE) &dbregs, 0) == -1)
if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & dbregs, 0) == -1)
#if 0
perror_with_name ("Couldn't read debug registers");
#else

View File

@ -132,10 +132,10 @@ gnu_fetch_registers (int regno)
/* Make sure we know about new threads. */
inf_update_procs (current_inferior);
thread = inf_tid_to_thread (current_inferior, inferior_pid);
thread = inf_tid_to_thread (current_inferior, PIDGET (inferior_ptid));
if (!thread)
error ("Can't fetch registers from thread %d: No such thread",
inferior_pid);
PIDGET (inferior_ptid));
if (regno < NUM_GREGS || regno == -1)
{
@ -256,10 +256,10 @@ gnu_store_registers (int regno)
/* Make sure we know about new threads. */
inf_update_procs (current_inferior);
thread = inf_tid_to_thread (current_inferior, inferior_pid);
thread = inf_tid_to_thread (current_inferior, PIDGET (inferior_ptid));
if (!thread)
error ("Couldn't store registers into thread %d: No such thread",
inferior_pid);
PIDGET (inferior_ptid));
if (regno < NUM_GREGS || regno == -1)
{

View File

@ -49,9 +49,9 @@ fetch_inferior_registers (int regno)
registers_fetched ();
ptrace (PTRACE_GETREGS, inferior_pid,
ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers);
ptrace (PTRACE_GETFPREGS, inferior_pid,
ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_fp_registers);
memcpy (registers, &inferior_registers, sizeof inferior_registers);
@ -88,23 +88,26 @@ store_inferior_registers (int regno)
instruction that moves eax into ebp gets single-stepped. */
{
int stack = inferior_registers.r_reg[SP_REGNUM];
int stuff = ptrace (PTRACE_PEEKDATA, inferior_pid,
int stuff = ptrace (PTRACE_PEEKDATA, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) stack);
int reg = inferior_registers.r_reg[EAX];
inferior_registers.r_reg[EAX] =
inferior_registers.r_reg[FP_REGNUM];
ptrace (PTRACE_SETREGS, inferior_pid,
ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers);
ptrace (PTRACE_POKEDATA, inferior_pid, (PTRACE_ARG3_TYPE) stack, 0xc589);
ptrace (PTRACE_SINGLESTEP, inferior_pid, (PTRACE_ARG3_TYPE) stack, 0);
ptrace (PTRACE_POKEDATA, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) stack, 0xc589);
ptrace (PTRACE_SINGLESTEP, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) stack, 0);
wait (0);
ptrace (PTRACE_POKEDATA, inferior_pid, (PTRACE_ARG3_TYPE) stack, stuff);
ptrace (PTRACE_POKEDATA, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) stack, stuff);
inferior_registers.r_reg[EAX] = reg;
}
#endif
ptrace (PTRACE_SETREGS, inferior_pid,
ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers);
ptrace (PTRACE_SETFPREGS, inferior_pid,
ptrace (PTRACE_SETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_fp_registers);
}

View File

@ -57,9 +57,9 @@ fetch_inferior_registers (int regno)
struct reg inferior_registers;
struct env387 inferior_fpregisters;
ptrace (PT_GETREGS, inferior_pid,
ptrace (PT_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &inferior_registers, 0);
ptrace (PT_GETFPREGS, inferior_pid,
ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &inferior_fpregisters, 0);
RF ( 0, inferior_registers.r_eax);
@ -142,9 +142,9 @@ store_inferior_registers (int regno)
RS (FDOFF_REGNUM, inferior_fpregisters.operand);
RS (FOP_REGNUM, inferior_fpregisters.opcode);
ptrace (PT_SETREGS, inferior_pid,
ptrace (PT_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &inferior_registers, 0);
ptrace (PT_SETFPREGS, inferior_pid,
ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &inferior_fpregisters, 0);
}

View File

@ -474,28 +474,28 @@ fill_fpregset (fpregset_t *fpregsetp, int regno)
#define IA64_PSR_DD (1UL << 39)
static void
enable_watchpoints_in_psr (int pid)
enable_watchpoints_in_psr (ptid_t ptid)
{
CORE_ADDR psr;
psr = read_register_pid (IA64_PSR_REGNUM, pid);
psr = read_register_pid (IA64_PSR_REGNUM, ptid);
if (!(psr & IA64_PSR_DB))
{
psr |= IA64_PSR_DB; /* Set the db bit - this enables hardware
watchpoints and breakpoints. */
write_register_pid (IA64_PSR_REGNUM, psr, pid);
write_register_pid (IA64_PSR_REGNUM, psr, ptid);
}
}
static long
fetch_debug_register (int pid, int idx)
fetch_debug_register (ptid_t ptid, int idx)
{
long val;
int tid;
tid = TIDGET(pid);
tid = TIDGET (ptid);
if (tid == 0)
tid = pid;
tid = PIDGET (ptid);
val = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) (PT_DBR + 8 * idx), 0);
@ -503,33 +503,33 @@ fetch_debug_register (int pid, int idx)
}
static void
store_debug_register (int pid, int idx, long val)
store_debug_register (ptid_t ptid, int idx, long val)
{
int tid;
tid = TIDGET(pid);
tid = TIDGET (ptid);
if (tid == 0)
tid = pid;
tid = PIDGET (ptid);
(void) ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) (PT_DBR + 8 * idx), val);
}
static void
fetch_debug_register_pair (int pid, int idx, long *dbr_addr, long *dbr_mask)
fetch_debug_register_pair (ptid_t ptid, int idx, long *dbr_addr, long *dbr_mask)
{
if (dbr_addr)
*dbr_addr = fetch_debug_register (pid, 2 * idx);
*dbr_addr = fetch_debug_register (ptid, 2 * idx);
if (dbr_mask)
*dbr_mask = fetch_debug_register (pid, 2 * idx + 1);
*dbr_mask = fetch_debug_register (ptid, 2 * idx + 1);
}
static void
store_debug_register_pair (int pid, int idx, long *dbr_addr, long *dbr_mask)
store_debug_register_pair (ptid_t ptid, int idx, long *dbr_addr, long *dbr_mask)
{
if (dbr_addr)
store_debug_register (pid, 2 * idx, *dbr_addr);
store_debug_register (ptid, 2 * idx, *dbr_addr);
if (dbr_mask)
store_debug_register (pid, 2 * idx + 1, *dbr_mask);
store_debug_register (ptid, 2 * idx + 1, *dbr_mask);
}
static int
@ -546,7 +546,7 @@ is_power_of_2 (int val)
}
int
ia64_linux_insert_watchpoint (int pid, CORE_ADDR addr, int len, int rw)
ia64_linux_insert_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rw)
{
int idx;
long dbr_addr, dbr_mask;
@ -557,7 +557,7 @@ ia64_linux_insert_watchpoint (int pid, CORE_ADDR addr, int len, int rw)
for (idx = 0; idx < max_watchpoints; idx++)
{
fetch_debug_register_pair (pid, idx, NULL, &dbr_mask);
fetch_debug_register_pair (ptid, idx, NULL, &dbr_mask);
if ((dbr_mask & (0x3UL << 62)) == 0)
{
/* Exit loop if both r and w bits clear */
@ -586,14 +586,14 @@ ia64_linux_insert_watchpoint (int pid, CORE_ADDR addr, int len, int rw)
return -1;
}
store_debug_register_pair (pid, idx, &dbr_addr, &dbr_mask);
enable_watchpoints_in_psr (pid);
store_debug_register_pair (ptid, idx, &dbr_addr, &dbr_mask);
enable_watchpoints_in_psr (ptid);
return 0;
}
int
ia64_linux_remove_watchpoint (int pid, CORE_ADDR addr, int len)
ia64_linux_remove_watchpoint (ptid_t ptid, CORE_ADDR addr, int len)
{
int idx;
long dbr_addr, dbr_mask;
@ -604,12 +604,12 @@ ia64_linux_remove_watchpoint (int pid, CORE_ADDR addr, int len)
for (idx = 0; idx < max_watchpoints; idx++)
{
fetch_debug_register_pair (pid, idx, &dbr_addr, &dbr_mask);
fetch_debug_register_pair (ptid, idx, &dbr_addr, &dbr_mask);
if ((dbr_mask & (0x3UL << 62)) && addr == (CORE_ADDR) dbr_addr)
{
dbr_addr = 0;
dbr_mask = 0;
store_debug_register_pair (pid, idx, &dbr_addr, &dbr_mask);
store_debug_register_pair (ptid, idx, &dbr_addr, &dbr_mask);
return 0;
}
}
@ -617,15 +617,15 @@ ia64_linux_remove_watchpoint (int pid, CORE_ADDR addr, int len)
}
CORE_ADDR
ia64_linux_stopped_by_watchpoint (int pid)
ia64_linux_stopped_by_watchpoint (ptid_t ptid)
{
CORE_ADDR psr;
int tid;
struct siginfo siginfo;
tid = TIDGET(pid);
tid = TIDGET(ptid);
if (tid == 0)
tid = pid;
tid = PIDGET (ptid);
errno = 0;
ptrace (PTRACE_GETSIGINFO, tid, (PTRACE_ARG3_TYPE) 0, &siginfo);
@ -633,10 +633,10 @@ ia64_linux_stopped_by_watchpoint (int pid)
if (errno != 0 || (siginfo.si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */)
return 0;
psr = read_register_pid (IA64_PSR_REGNUM, pid);
psr = read_register_pid (IA64_PSR_REGNUM, ptid);
psr |= IA64_PSR_DD; /* Set the dd bit - this will disable the watchpoint
for the next instruction */
write_register_pid (IA64_PSR_REGNUM, psr, pid);
write_register_pid (IA64_PSR_REGNUM, psr, ptid);
return (CORE_ADDR) siginfo.si_addr;
}

View File

@ -612,27 +612,27 @@ ia64_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
}
CORE_ADDR
ia64_read_pc (int pid)
ia64_read_pc (ptid_t ptid)
{
CORE_ADDR psr_value = read_register_pid (IA64_PSR_REGNUM, pid);
CORE_ADDR pc_value = read_register_pid (IA64_IP_REGNUM, pid);
CORE_ADDR psr_value = read_register_pid (IA64_PSR_REGNUM, ptid);
CORE_ADDR pc_value = read_register_pid (IA64_IP_REGNUM, ptid);
int slot_num = (psr_value >> 41) & 3;
return pc_value | (slot_num * SLOT_MULTIPLIER);
}
void
ia64_write_pc (CORE_ADDR new_pc, int pid)
ia64_write_pc (CORE_ADDR new_pc, ptid_t ptid)
{
int slot_num = (int) (new_pc & 0xf) / SLOT_MULTIPLIER;
CORE_ADDR psr_value = read_register_pid (IA64_PSR_REGNUM, pid);
CORE_ADDR psr_value = read_register_pid (IA64_PSR_REGNUM, ptid);
psr_value &= ~(3LL << 41);
psr_value |= (CORE_ADDR)(slot_num & 0x3) << 41;
new_pc &= ~0xfLL;
write_register_pid (IA64_PSR_REGNUM, psr_value, pid);
write_register_pid (IA64_IP_REGNUM, new_pc, pid);
write_register_pid (IA64_PSR_REGNUM, psr_value, ptid);
write_register_pid (IA64_IP_REGNUM, new_pc, ptid);
}
#define IS_NaT_COLLECTION_ADDR(addr) ((((addr) >> 3) & 0x3f) == 0x3f)

View File

@ -131,7 +131,7 @@ char *inferior_io_terminal;
being debugged it should be nonzero (currently 3 is used) for remote
debugging. */
int inferior_pid;
ptid_t inferior_ptid;
/* Last signal that the inferior received (why it stopped). */
@ -258,7 +258,7 @@ run_command (char *args, int from_tty)
dont_repeat ();
if (inferior_pid != 0 && target_has_execution)
if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
{
if (from_tty
&& !query ("The program being debugged has been started already.\n\
@ -1690,7 +1690,7 @@ attach_command (char *args, int from_tty)
exec_file = (char *) get_exec_file (0);
if (!exec_file)
{
exec_file = target_pid_to_exec_file (inferior_pid);
exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
if (exec_file)
{
/* It's possible we don't have a full path, but rather just a
@ -1720,7 +1720,7 @@ attach_command (char *args, int from_tty)
/* Take any necessary post-attaching actions for this platform.
*/
target_post_attach (inferior_pid);
target_post_attach (PIDGET (inferior_ptid));
normal_stop ();

View File

@ -63,9 +63,10 @@ extern void clear_sigio_trap (void);
extern char *inferior_io_terminal;
/* Pid of our debugged inferior, or 0 if no inferior now. */
/* Collected pid, tid, etc. of the debugged inferior. When there's
no inferior, PIDGET (inferior_ptid) will be 0. */
extern int inferior_pid;
extern ptid_t inferior_ptid;
/* Is the inferior running right now, as a result of a 'run&',
'continue&' etc command? This is used in asycn gdb to determine
@ -78,7 +79,7 @@ extern int target_executing;
redisplay the prompt until the execution is actually over. */
extern int sync_execution;
/* This is only valid when inferior_pid is non-zero.
/* This is only valid when inferior_ptid is non-zero.
If this is 0, then exec events should be noticed and responded to
by the debugger (i.e., be reported to the user).
@ -122,15 +123,15 @@ extern int run_stack_dummy (CORE_ADDR, char *);
extern CORE_ADDR read_pc (void);
extern CORE_ADDR read_pc_pid (int);
extern CORE_ADDR read_pc_pid (ptid_t);
extern CORE_ADDR generic_target_read_pc (int);
extern CORE_ADDR generic_target_read_pc (ptid_t);
extern void write_pc (CORE_ADDR);
extern void write_pc_pid (CORE_ADDR, int);
extern void write_pc_pid (CORE_ADDR, ptid_t);
extern void generic_target_write_pc (CORE_ADDR, int);
extern void generic_target_write_pc (CORE_ADDR, ptid_t);
extern CORE_ADDR read_sp (void);
@ -208,9 +209,9 @@ extern int attach (int);
extern void detach (int);
/* PTRACE method of waiting for inferior process. */
int ptrace_wait (int, int *);
int ptrace_wait (ptid_t, int *);
extern void child_resume (int, int, enum target_signal);
extern void child_resume (ptid_t, int, enum target_signal);
#ifndef PTRACE_ARG3_TYPE
#define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */
@ -224,7 +225,7 @@ extern void pre_fork_inferior (void);
extern int proc_iterate_over_mappings (int (*)(int, CORE_ADDR));
extern int procfs_first_available (void);
extern ptid_t procfs_first_available (void);
/* From fork-child.c */
@ -261,7 +262,8 @@ extern int signal_print_update (int, int);
extern int signal_pass_update (int, int);
extern void get_last_target_status(int *pid, struct target_waitstatus *status);
extern void get_last_target_status(ptid_t *ptid,
struct target_waitstatus *status);
/* From infcmd.c */
@ -362,7 +364,7 @@ extern int proceed_to_finish;
extern char *stop_registers;
/* Nonzero if the child process in inferior_pid was attached rather
/* Nonzero if the child process in inferior_ptid was attached rather
than forked. */
extern int attach_flag;

View File

@ -207,9 +207,9 @@ terminal_init_inferior (void)
debugging target with a version of target_terminal_init_inferior which
passes in the process group to a generic routine which does all the work
(and the non-threaded child_terminal_init_inferior can just pass in
inferior_pid to the same routine). */
inferior_ptid to the same routine). */
/* We assume INFERIOR_PID is also the child's process group. */
terminal_init_inferior_with_pgrp (PIDGET (inferior_pid));
terminal_init_inferior_with_pgrp (PIDGET (inferior_ptid));
#endif /* PROCESS_GROUP_TYPE */
}
@ -573,11 +573,11 @@ new_tty (void)
static void
kill_command (char *arg, int from_tty)
{
/* FIXME: This should not really be inferior_pid (or target_has_execution).
/* FIXME: This should not really be inferior_ptid (or target_has_execution).
It should be a distinct flag that indicates that a target is active, cuz
some targets don't have processes! */
if (inferior_pid == 0)
if (ptid_equal (inferior_ptid, null_ptid))
error ("The program is not being run.");
if (!query ("Kill the program being debugged? "))
error ("Not confirmed.");
@ -605,7 +605,7 @@ static void
pass_signal (int signo)
{
#ifndef _WIN32
kill (PIDGET (inferior_pid), SIGINT);
kill (PIDGET (inferior_ptid), SIGINT);
#endif
}
@ -647,7 +647,7 @@ handle_sigio (int signo)
{
#ifndef _WIN32
if ((*target_activity_function) ())
kill (inferior_pid, SIGINT);
kill (PIDGET (inferior_ptid), SIGINT);
#endif
}
}
@ -735,7 +735,7 @@ _initialize_inflow (void)
add_com ("kill", class_run, kill_command,
"Kill execution of program being debugged.");
inferior_pid = 0;
inferior_ptid = null_ptid;
terminal_is_ours = 1;

View File

@ -215,12 +215,12 @@ call_ptrace (int request, int pid, PTRACE_ARG3_TYPE addr, int data)
hook before returning. */
int
ptrace_wait (int pid, int *status)
ptrace_wait (ptid_t ptid, int *status)
{
int wstate;
wstate = wait (status);
target_post_wait (wstate, *status);
target_post_wait (pid_to_ptid (wstate), *status);
return wstate;
}
@ -228,8 +228,9 @@ void
kill_inferior (void)
{
int status;
int pid = PIDGET (inferior_ptid);
if (inferior_pid == 0)
if (pid == 0)
return;
/* This once used to call "kill" to kill the inferior just in case
@ -240,8 +241,8 @@ kill_inferior (void)
The kill call causes problems under hpux10, so it's been removed;
if this causes problems we'll deal with them as they arise. */
ptrace (PT_KILL, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0);
ptrace_wait (0, &status);
ptrace (PT_KILL, pid, (PTRACE_ARG3_TYPE) 0, 0);
ptrace_wait (null_ptid, &status);
target_mourn_inferior ();
}
@ -252,15 +253,17 @@ kill_inferior (void)
If SIGNAL is nonzero, give it that signal. */
void
child_resume (int pid, int step, enum target_signal signal)
child_resume (ptid_t ptid, int step, enum target_signal signal)
{
int pid = PIDGET (ptid);
errno = 0;
if (pid == -1)
/* Resume all threads. */
/* I think this only gets used in the non-threaded case, where "resume
all threads" and "resume inferior_pid" are the same. */
pid = inferior_pid;
all threads" and "resume inferior_ptid" are the same. */
pid = PIDGET (inferior_ptid);
/* An address of (PTRACE_ARG3_TYPE)1 tells ptrace to continue from where
it was. (If GDB wanted it to start some other way, we have already
@ -312,7 +315,8 @@ void
detach (int signal)
{
errno = 0;
ptrace (PT_DETACH, inferior_pid, (PTRACE_ARG3_TYPE) 1, signal);
ptrace (PT_DETACH, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) 1,
signal);
if (errno)
perror_with_name ("ptrace");
attach_flag = 0;
@ -356,7 +360,7 @@ _initialize_kernel_u_addr (void)
/* U_REGS_OFFSET is the offset of the registers within the u area. */
#if !defined (U_REGS_OFFSET)
#define U_REGS_OFFSET \
ptrace (PT_READ_U, inferior_pid, \
ptrace (PT_READ_U, PIDGET (inferior_ptid), \
(PTRACE_ARG3_TYPE) (offsetof (struct user, u_ar0)), 0) \
- KERNEL_U_ADDR
#endif
@ -387,8 +391,8 @@ fetch_register (int regno)
}
/* Overload thread id onto process id */
if ((tid = TIDGET (inferior_pid)) == 0)
tid = inferior_pid; /* no thread id, just use process id */
if ((tid = TIDGET (inferior_ptid)) == 0)
tid = PIDGET (inferior_ptid); /* no thread id, just use process id */
offset = U_REGS_OFFSET;
@ -453,8 +457,8 @@ store_register (int regno)
}
/* Overload thread id onto process id */
if ((tid = TIDGET (inferior_pid)) == 0)
tid = inferior_pid; /* no thread id, just use process id */
if ((tid = TIDGET (inferior_ptid)) == 0)
tid = PIDGET (inferior_ptid); /* no thread id, just use process id */
offset = U_REGS_OFFSET;
@ -535,14 +539,14 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
if (addr != memaddr || len < (int) sizeof (PTRACE_XFER_TYPE))
{
/* Need part of initial word -- fetch it. */
buffer[0] = ptrace (PT_READ_I, PIDGET (inferior_pid),
buffer[0] = ptrace (PT_READ_I, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr, 0);
}
if (count > 1) /* FIXME, avoid if even boundary */
{
buffer[count - 1]
= ptrace (PT_READ_I, PIDGET (inferior_pid),
= ptrace (PT_READ_I, PIDGET (inferior_ptid),
((PTRACE_ARG3_TYPE)
(addr + (count - 1) * sizeof (PTRACE_XFER_TYPE))),
0);
@ -559,14 +563,14 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
ptrace (PT_WRITE_D, PIDGET (inferior_pid),
ptrace (PT_WRITE_D, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr, buffer[i]);
if (errno)
{
/* Using the appropriate one (I or D) is necessary for
Gould NP1, at least. */
errno = 0;
ptrace (PT_WRITE_I, PIDGET (inferior_pid),
ptrace (PT_WRITE_I, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr, buffer[i]);
}
if (errno)
@ -582,7 +586,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
buffer[i] = ptrace (PT_READ_I, PIDGET (inferior_pid),
buffer[i] = ptrace (PT_READ_I, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr, 0);
if (errno)
return 0;
@ -632,7 +636,7 @@ udot_info (char *dummy1, int dummy2)
}
printf_filtered ("%04x:", udot_off);
}
udot_val = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) udot_off, 0);
udot_val = ptrace (PT_READ_U, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) udot_off, 0);
if (errno != 0)
{
sprintf (mess, "\nreading user struct at offset 0x%x", udot_off);

View File

@ -99,7 +99,7 @@ int sync_execution = 0;
when the inferior stopped in a different thread than it had been
running in. */
static int previous_inferior_pid;
static ptid_t previous_inferior_ptid;
/* This is true for configurations that may follow through execl() and
similar functions. At present this is only true for HP-UX native. */
@ -332,6 +332,9 @@ static unsigned char *signal_program;
(flags)[signum] = 0; \
} while (0)
/* Value to pass to target_resume() to cause all threads to resume */
#define RESUME_ALL (pid_to_ptid (-1))
/* Command list pointer for the "stop" placeholder. */
@ -409,7 +412,7 @@ static int number_of_threads_in_syscalls;
/* This is a cached copy of the pid/waitstatus of the last event
returned by target_wait()/target_wait_hook(). This information is
returned by get_last_target_status(). */
static int target_last_wait_pid = -1;
static ptid_t target_last_wait_ptid;
static struct target_waitstatus target_last_waitstatus;
/* This is used to remember when a fork, vfork or exec event
@ -441,7 +444,7 @@ pending_follow;
set to 1, a vfork event has been seen, but cannot be followed
until the exec is seen.
(In the latter case, inferior_pid is still the parent of the
(In the latter case, inferior_ptid is still the parent of the
vfork, and pending_follow.fork_event.child_pid is the child. The
appropriate process is followed, according to the setting of
follow-fork-mode.) */
@ -513,7 +516,7 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked,
}
/* If we're to be following the child, then attach to it, detach
from inferior_pid, and set inferior_pid to child_pid. */
from inferior_ptid, and set inferior_ptid to child_pid. */
else if (follow_mode == follow_fork_mode_child)
{
char child_pid_spelling[100]; /* Arbitrary length. */
@ -536,7 +539,7 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked,
/* Also reset the solib inferior hook from the parent. */
#ifdef SOLIB_REMOVE_INFERIOR_HOOK
SOLIB_REMOVE_INFERIOR_HOOK (inferior_pid);
SOLIB_REMOVE_INFERIOR_HOOK (PIDGET (inferior_ptid));
#endif
/* Detach from the parent. */
@ -544,7 +547,7 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked,
target_detach (NULL, 1);
/* Attach to the child. */
inferior_pid = child_pid;
inferior_ptid = pid_to_ptid (child_pid);
sprintf (child_pid_spelling, "%d", child_pid);
dont_repeat ();
@ -588,7 +591,7 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked,
/* We continue to follow the parent. To help distinguish the two
debuggers, though, both we and our clone will reset our prompts. */
sprintf (pid_suffix, "[%d] ", inferior_pid);
sprintf (pid_suffix, "[%d] ", PIDGET (inferior_ptid));
set_prompt (strcat (get_prompt (), pid_suffix));
}
@ -650,11 +653,12 @@ follow_vfork (int parent_pid, int child_pid)
follow_inferior_fork (parent_pid, child_pid, 0, 1);
/* Did we follow the child? Had it exec'd before we saw the parent vfork? */
if (pending_follow.fork_event.saw_child_exec && (inferior_pid == child_pid))
if (pending_follow.fork_event.saw_child_exec
&& (PIDGET (inferior_ptid) == child_pid))
{
pending_follow.fork_event.saw_child_exec = 0;
pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
follow_exec (inferior_pid, pending_follow.execd_pathname);
follow_exec (PIDGET (inferior_ptid), pending_follow.execd_pathname);
xfree (pending_follow.execd_pathname);
}
}
@ -676,13 +680,14 @@ follow_exec (int pid, char *execd_pathname)
(pending_follow.kind == TARGET_WAITKIND_VFORKED))
{
pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
follow_vfork (inferior_pid, pending_follow.fork_event.child_pid);
follow_vfork (PIDGET (inferior_ptid),
pending_follow.fork_event.child_pid);
follow_vfork_when_exec = 0;
saved_pid = inferior_pid;
saved_pid = PIDGET (inferior_ptid);
/* Did we follow the parent? If so, we're done. If we followed
the child then we must also follow its exec(). */
if (inferior_pid == pending_follow.fork_event.parent_pid)
if (PIDGET (inferior_ptid) == pending_follow.fork_event.parent_pid)
return;
}
@ -731,7 +736,8 @@ follow_exec (int pid, char *execd_pathname)
gdb_flush (gdb_stdout);
target_mourn_inferior ();
inferior_pid = saved_pid; /* Because mourn_inferior resets inferior_pid. */
inferior_ptid = pid_to_ptid (saved_pid);
/* Because mourn_inferior resets inferior_ptid. */
push_target (tgt);
/* That a.out is now the one to use. */
@ -747,7 +753,7 @@ follow_exec (int pid, char *execd_pathname)
SOLIB_RESTART ();
#endif
#ifdef SOLIB_CREATE_INFERIOR_HOOK
SOLIB_CREATE_INFERIOR_HOOK (inferior_pid);
SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
#endif
/* Reinsert all breakpoints. (Those which were symbolic have
@ -866,7 +872,8 @@ resume (int step, enum target_signal sig)
{
case (TARGET_WAITKIND_FORKED):
pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
follow_fork (inferior_pid, pending_follow.fork_event.child_pid);
follow_fork (PIDGET (inferior_ptid),
pending_follow.fork_event.child_pid);
break;
case (TARGET_WAITKIND_VFORKED):
@ -874,14 +881,15 @@ resume (int step, enum target_signal sig)
int saw_child_exec = pending_follow.fork_event.saw_child_exec;
pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
follow_vfork (inferior_pid, pending_follow.fork_event.child_pid);
follow_vfork (PIDGET (inferior_ptid),
pending_follow.fork_event.child_pid);
/* Did we follow the child, but not yet see the child's exec event?
If so, then it actually ought to be waiting for us; we respond to
parent vfork events. We don't actually want to resume the child
in this situation; we want to just get its exec event. */
if (!saw_child_exec &&
(inferior_pid == pending_follow.fork_event.child_pid))
(PIDGET (inferior_ptid) == pending_follow.fork_event.child_pid))
should_resume = 0;
}
break;
@ -902,7 +910,7 @@ resume (int step, enum target_signal sig)
if (should_resume)
{
int resume_pid;
ptid_t resume_ptid;
if (use_thread_step_needed && thread_step_needed)
{
@ -915,7 +923,7 @@ resume (int step, enum target_signal sig)
{
/* Breakpoint deleted: ok to do regular resume
where all the threads either step or continue. */
resume_pid = -1;
resume_ptid = RESUME_ALL;
}
else
{
@ -927,7 +935,7 @@ resume (int step, enum target_signal sig)
trap_expected = 1;
step = 1;
}
resume_pid = inferior_pid;
resume_ptid = inferior_ptid;
}
}
else
@ -935,11 +943,11 @@ resume (int step, enum target_signal sig)
/* Vanilla resume. */
if ((scheduler_mode == schedlock_on) ||
(scheduler_mode == schedlock_step && step != 0))
resume_pid = inferior_pid;
resume_ptid = inferior_ptid;
else
resume_pid = -1;
resume_ptid = RESUME_ALL;
}
target_resume (resume_pid, step, sig);
target_resume (resume_ptid, step, sig);
}
discard_cleanups (old_cleanups);
@ -1230,8 +1238,8 @@ struct execution_control_state
int current_line;
struct symtab *current_symtab;
int handling_longjmp; /* FIXME */
int pid;
int saved_inferior_pid;
ptid_t ptid;
ptid_t saved_inferior_ptid;
int update_step_sp;
int stepping_through_solib_after_catch;
bpstat stepping_through_solib_catchpoints;
@ -1240,7 +1248,7 @@ struct execution_control_state
int new_thread_event;
struct target_waitstatus tmpstatus;
enum infwait_states infwait_state;
int waiton_pid;
ptid_t waiton_ptid;
int wait_some_more;
};
@ -1284,7 +1292,7 @@ wait_for_inferior (void)
thread_step_needed = 0;
/* We'll update this if & when we switch to a new thread. */
previous_inferior_pid = inferior_pid;
previous_inferior_ptid = inferior_ptid;
overlay_cache_invalid = 1;
@ -1299,9 +1307,9 @@ wait_for_inferior (void)
while (1)
{
if (target_wait_hook)
ecs->pid = target_wait_hook (ecs->waiton_pid, ecs->wp);
ecs->ptid = target_wait_hook (ecs->waiton_ptid, ecs->wp);
else
ecs->pid = target_wait (ecs->waiton_pid, ecs->wp);
ecs->ptid = target_wait (ecs->waiton_ptid, ecs->wp);
/* Now figure out what to do with the result of the result. */
handle_inferior_event (ecs);
@ -1344,7 +1352,7 @@ fetch_inferior_event (void *client_data)
thread_step_needed = 0;
/* We'll update this if & when we switch to a new thread. */
previous_inferior_pid = inferior_pid;
previous_inferior_ptid = inferior_ptid;
overlay_cache_invalid = 1;
@ -1358,9 +1366,9 @@ fetch_inferior_event (void *client_data)
}
if (target_wait_hook)
async_ecs->pid = target_wait_hook (async_ecs->waiton_pid, async_ecs->wp);
async_ecs->ptid = target_wait_hook (async_ecs->waiton_ptid, async_ecs->wp);
else
async_ecs->pid = target_wait (async_ecs->waiton_pid, async_ecs->wp);
async_ecs->ptid = target_wait (async_ecs->waiton_ptid, async_ecs->wp);
/* Now figure out what to do with the result of the result. */
handle_inferior_event (async_ecs);
@ -1398,7 +1406,7 @@ init_execution_control_state (struct execution_control_state *ecs)
ecs->current_line = ecs->sal.line;
ecs->current_symtab = ecs->sal.symtab;
ecs->infwait_state = infwait_normal_state;
ecs->waiton_pid = -1;
ecs->waiton_ptid = pid_to_ptid (-1);
ecs->wp = &(ecs->ws);
}
@ -1419,9 +1427,9 @@ check_for_old_step_resume_breakpoint (void)
target_wait()/target_wait_hook(). */
void
get_last_target_status(int *pid, struct target_waitstatus *status)
get_last_target_status(ptid_t *ptidp, struct target_waitstatus *status)
{
*pid = target_last_wait_pid;
*ptidp = target_last_wait_ptid;
*status = target_last_waitstatus;
}
@ -1436,7 +1444,7 @@ handle_inferior_event (struct execution_control_state *ecs)
int stepped_after_stopped_by_watchpoint;
/* Cache the last pid/waitstatus. */
target_last_wait_pid = ecs->pid;
target_last_wait_ptid = ecs->ptid;
target_last_waitstatus = *ecs->wp;
/* Keep this extra brace for now, minimizes diffs. */
@ -1453,7 +1461,7 @@ handle_inferior_event (struct execution_control_state *ecs)
is serviced in this loop, below. */
if (ecs->enable_hw_watchpoints_after_wait)
{
TARGET_ENABLE_HW_WATCHPOINTS (inferior_pid);
TARGET_ENABLE_HW_WATCHPOINTS (PIDGET (inferior_ptid));
ecs->enable_hw_watchpoints_after_wait = 0;
}
stepped_after_stopped_by_watchpoint = 0;
@ -1467,9 +1475,9 @@ handle_inferior_event (struct execution_control_state *ecs)
* FIXME: shouldn't we look at currently_stepping ()?
*/
if (scheduler_mode == schedlock_on)
target_resume (ecs->pid, 0, TARGET_SIGNAL_0);
target_resume (ecs->ptid, 0, TARGET_SIGNAL_0);
else
target_resume (-1, 0, TARGET_SIGNAL_0);
target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0);
ecs->infwait_state = infwait_normal_state;
prepare_to_wait (ecs);
return;
@ -1492,20 +1500,21 @@ handle_inferior_event (struct execution_control_state *ecs)
/* If it's a new process, add it to the thread database */
ecs->new_thread_event = ((ecs->pid != inferior_pid) && !in_thread_list (ecs->pid));
ecs->new_thread_event = (! ptid_equal (ecs->ptid, inferior_ptid)
&& ! in_thread_list (ecs->ptid));
if (ecs->ws.kind != TARGET_WAITKIND_EXITED
&& ecs->ws.kind != TARGET_WAITKIND_SIGNALLED
&& ecs->new_thread_event)
{
add_thread (ecs->pid);
add_thread (ecs->ptid);
#ifdef UI_OUT
ui_out_text (uiout, "[New ");
ui_out_text (uiout, target_pid_or_tid_to_str (ecs->pid));
ui_out_text (uiout, target_pid_or_tid_to_str (ecs->ptid));
ui_out_text (uiout, "]\n");
#else
printf_filtered ("[New %s]\n", target_pid_or_tid_to_str (ecs->pid));
printf_filtered ("[New %s]\n", target_pid_or_tid_to_str (ecs->ptid));
#endif
#if 0
@ -1528,7 +1537,7 @@ handle_inferior_event (struct execution_control_state *ecs)
Therefore we need to continue all threads in order to
make progress. */
target_resume (-1, 0, TARGET_SIGNAL_0);
target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0);
prepare_to_wait (ecs);
return;
#endif
@ -1616,10 +1625,10 @@ handle_inferior_event (struct execution_control_state *ecs)
interested in reacting to forks of the child. Note that
we expect the child's fork event to be available if we
waited for it now. */
if (inferior_pid == ecs->pid)
if (ptid_equal (inferior_ptid, ecs->ptid))
{
pending_follow.fork_event.saw_parent_fork = 1;
pending_follow.fork_event.parent_pid = ecs->pid;
pending_follow.fork_event.parent_pid = PIDGET (ecs->ptid);
pending_follow.fork_event.child_pid = ecs->ws.value.related_pid;
prepare_to_wait (ecs);
return;
@ -1627,16 +1636,16 @@ handle_inferior_event (struct execution_control_state *ecs)
else
{
pending_follow.fork_event.saw_child_fork = 1;
pending_follow.fork_event.child_pid = ecs->pid;
pending_follow.fork_event.child_pid = PIDGET (ecs->ptid);
pending_follow.fork_event.parent_pid = ecs->ws.value.related_pid;
}
stop_pc = read_pc_pid (ecs->pid);
ecs->saved_inferior_pid = inferior_pid;
inferior_pid = ecs->pid;
stop_pc = read_pc_pid (ecs->ptid);
ecs->saved_inferior_ptid = inferior_ptid;
inferior_ptid = ecs->ptid;
stop_bpstat = bpstat_stop_status (&stop_pc, currently_stepping (ecs));
ecs->random_signal = !bpstat_explains_signal (stop_bpstat);
inferior_pid = ecs->saved_inferior_pid;
inferior_ptid = ecs->saved_inferior_ptid;
goto process_event_stop_test;
/* If this a platform which doesn't allow a debugger to touch a
@ -1656,10 +1665,10 @@ handle_inferior_event (struct execution_control_state *ecs)
it execs, and the child has not yet exec'd. We probably
should warn the user to that effect when the catchpoint
triggers...) */
if (ecs->pid == inferior_pid)
if (ptid_equal (ecs->ptid, inferior_ptid))
{
pending_follow.fork_event.saw_parent_fork = 1;
pending_follow.fork_event.parent_pid = ecs->pid;
pending_follow.fork_event.parent_pid = PIDGET (ecs->ptid);
pending_follow.fork_event.child_pid = ecs->ws.value.related_pid;
}
@ -1669,13 +1678,14 @@ handle_inferior_event (struct execution_control_state *ecs)
else
{
pending_follow.fork_event.saw_child_fork = 1;
pending_follow.fork_event.child_pid = ecs->pid;
pending_follow.fork_event.child_pid = PIDGET (ecs->ptid);
pending_follow.fork_event.parent_pid = ecs->ws.value.related_pid;
target_post_startup_inferior (pending_follow.fork_event.child_pid);
target_post_startup_inferior (
pid_to_ptid (pending_follow.fork_event.child_pid));
follow_vfork_when_exec = !target_can_follow_vfork_prior_to_exec ();
if (follow_vfork_when_exec)
{
target_resume (ecs->pid, 0, TARGET_SIGNAL_0);
target_resume (ecs->ptid, 0, TARGET_SIGNAL_0);
prepare_to_wait (ecs);
return;
}
@ -1698,7 +1708,7 @@ handle_inferior_event (struct execution_control_state *ecs)
inferior_ignoring_leading_exec_events--;
if (pending_follow.kind == TARGET_WAITKIND_VFORKED)
ENSURE_VFORKING_PARENT_REMAINS_STOPPED (pending_follow.fork_event.parent_pid);
target_resume (ecs->pid, 0, TARGET_SIGNAL_0);
target_resume (ecs->ptid, 0, TARGET_SIGNAL_0);
prepare_to_wait (ecs);
return;
}
@ -1709,7 +1719,7 @@ handle_inferior_event (struct execution_control_state *ecs)
savestring (ecs->ws.value.execd_pathname,
strlen (ecs->ws.value.execd_pathname));
/* Did inferior_pid exec, or did a (possibly not-yet-followed)
/* Did inferior_ptid exec, or did a (possibly not-yet-followed)
child of a vfork exec?
??rehrauer: This is unabashedly an HP-UX specific thing. On
@ -1733,7 +1743,7 @@ handle_inferior_event (struct execution_control_state *ecs)
the parent vfork event is delivered. A single-step
suffices. */
if (RESUME_EXECD_VFORKING_CHILD_TO_GET_PARENT_VFORK ())
target_resume (ecs->pid, 1, TARGET_SIGNAL_0);
target_resume (ecs->ptid, 1, TARGET_SIGNAL_0);
/* We expect the parent vfork event to be available now. */
prepare_to_wait (ecs);
return;
@ -1741,15 +1751,15 @@ handle_inferior_event (struct execution_control_state *ecs)
/* This causes the eventpoints and symbol table to be reset. Must
do this now, before trying to determine whether to stop. */
follow_exec (inferior_pid, pending_follow.execd_pathname);
follow_exec (PIDGET (inferior_ptid), pending_follow.execd_pathname);
xfree (pending_follow.execd_pathname);
stop_pc = read_pc_pid (ecs->pid);
ecs->saved_inferior_pid = inferior_pid;
inferior_pid = ecs->pid;
stop_pc = read_pc_pid (ecs->ptid);
ecs->saved_inferior_ptid = inferior_ptid;
inferior_ptid = ecs->ptid;
stop_bpstat = bpstat_stop_status (&stop_pc, currently_stepping (ecs));
ecs->random_signal = !bpstat_explains_signal (stop_bpstat);
inferior_pid = ecs->saved_inferior_pid;
inferior_ptid = ecs->saved_inferior_ptid;
goto process_event_stop_test;
/* These syscall events are returned on HP-UX, as part of its
@ -1773,7 +1783,7 @@ handle_inferior_event (struct execution_control_state *ecs)
number_of_threads_in_syscalls++;
if (number_of_threads_in_syscalls == 1)
{
TARGET_DISABLE_HW_WATCHPOINTS (inferior_pid);
TARGET_DISABLE_HW_WATCHPOINTS (PIDGET (inferior_ptid));
}
resume (0, TARGET_SIGNAL_0);
prepare_to_wait (ecs);
@ -1794,7 +1804,7 @@ handle_inferior_event (struct execution_control_state *ecs)
here, which will be serviced immediately after the target
is waited on. */
case TARGET_WAITKIND_SYSCALL_RETURN:
target_resume (ecs->pid, 1, TARGET_SIGNAL_0);
target_resume (ecs->ptid, 1, TARGET_SIGNAL_0);
if (number_of_threads_in_syscalls > 0)
{
@ -1830,12 +1840,12 @@ handle_inferior_event (struct execution_control_state *ecs)
all threads in order to make progress. */
if (ecs->new_thread_event)
{
target_resume (-1, 0, TARGET_SIGNAL_0);
target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0);
prepare_to_wait (ecs);
return;
}
stop_pc = read_pc_pid (ecs->pid);
stop_pc = read_pc_pid (ecs->ptid);
/* See if a thread hit a thread-specific breakpoint that was meant for
another thread. If so, then step that thread past the breakpoint,
@ -1850,13 +1860,13 @@ handle_inferior_event (struct execution_control_state *ecs)
{
ecs->random_signal = 0;
if (!breakpoint_thread_match (stop_pc - DECR_PC_AFTER_BREAK,
ecs->pid))
ecs->ptid))
{
int remove_status;
/* Saw a breakpoint, but it was hit by the wrong thread.
Just continue. */
write_pc_pid (stop_pc - DECR_PC_AFTER_BREAK, ecs->pid);
write_pc_pid (stop_pc - DECR_PC_AFTER_BREAK, ecs->ptid);
remove_status = remove_breakpoints ();
/* Did we fail to remove breakpoints? If so, try
@ -1868,15 +1878,15 @@ handle_inferior_event (struct execution_control_state *ecs)
then either :-) or execs. */
if (remove_status != 0)
{
write_pc_pid (stop_pc - DECR_PC_AFTER_BREAK + 4, ecs->pid);
write_pc_pid (stop_pc - DECR_PC_AFTER_BREAK + 4, ecs->ptid);
}
else
{ /* Single step */
target_resume (ecs->pid, 1, TARGET_SIGNAL_0);
target_resume (ecs->ptid, 1, TARGET_SIGNAL_0);
/* FIXME: What if a signal arrives instead of the
single-step happening? */
ecs->waiton_pid = ecs->pid;
ecs->waiton_ptid = ecs->ptid;
ecs->wp = &(ecs->ws);
ecs->infwait_state = infwait_thread_hop_state;
prepare_to_wait (ecs);
@ -1888,9 +1898,9 @@ handle_inferior_event (struct execution_control_state *ecs)
* FIXME: shouldn't we look at currently_stepping ()?
*/
if (scheduler_mode == schedlock_on)
target_resume (ecs->pid, 0, TARGET_SIGNAL_0);
target_resume (ecs->ptid, 0, TARGET_SIGNAL_0);
else
target_resume (-1, 0, TARGET_SIGNAL_0);
target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0);
prepare_to_wait (ecs);
return;
}
@ -1914,7 +1924,7 @@ handle_inferior_event (struct execution_control_state *ecs)
Note that if there's any kind of pending follow (i.e., of a fork,
vfork or exec), we don't want to do this now. Rather, we'll let
the next resume handle it. */
if ((ecs->pid != inferior_pid) &&
if (! ptid_equal (ecs->ptid, inferior_ptid) &&
(pending_follow.kind == TARGET_WAITKIND_SPURIOUS))
{
int printed = 0;
@ -1957,7 +1967,7 @@ handle_inferior_event (struct execution_control_state *ecs)
if (signal_program[stop_signal] == 0)
stop_signal = TARGET_SIGNAL_0;
target_resume (ecs->pid, 0, stop_signal);
target_resume (ecs->ptid, 0, stop_signal);
prepare_to_wait (ecs);
return;
}
@ -1971,10 +1981,10 @@ handle_inferior_event (struct execution_control_state *ecs)
be lost. This may happen as a result of the target module
mishandling thread creation. */
if (in_thread_list (inferior_pid) && in_thread_list (ecs->pid))
if (in_thread_list (inferior_ptid) && in_thread_list (ecs->ptid))
{ /* Perform infrun state context switch: */
/* Save infrun state for the old thread. */
save_infrun_state (inferior_pid, prev_pc,
save_infrun_state (inferior_ptid, prev_pc,
prev_func_start, prev_func_name,
trap_expected, step_resume_breakpoint,
through_sigtramp_breakpoint,
@ -1986,7 +1996,7 @@ handle_inferior_event (struct execution_control_state *ecs)
ecs->stepping_through_sigtramp);
/* Load infrun state for the new thread. */
load_infrun_state (ecs->pid, &prev_pc,
load_infrun_state (ecs->ptid, &prev_pc,
&prev_func_start, &prev_func_name,
&trap_expected, &step_resume_breakpoint,
&through_sigtramp_breakpoint,
@ -1998,10 +2008,10 @@ handle_inferior_event (struct execution_control_state *ecs)
&ecs->stepping_through_sigtramp);
}
inferior_pid = ecs->pid;
inferior_ptid = ecs->ptid;
if (context_hook)
context_hook (pid_to_thread_id (ecs->pid));
context_hook (pid_to_thread_id (ecs->ptid));
flush_cached_frames ();
}
@ -2021,14 +2031,14 @@ handle_inferior_event (struct execution_control_state *ecs)
if (INSTRUCTION_NULLIFIED)
{
registers_changed ();
target_resume (ecs->pid, 1, TARGET_SIGNAL_0);
target_resume (ecs->ptid, 1, TARGET_SIGNAL_0);
/* We may have received a signal that we want to pass to
the inferior; therefore, we must not clobber the waitstatus
in WS. */
ecs->infwait_state = infwait_nullified_state;
ecs->waiton_pid = ecs->pid;
ecs->waiton_ptid = ecs->ptid;
ecs->wp = &(ecs->tmpstatus);
prepare_to_wait (ecs);
return;
@ -2070,9 +2080,9 @@ handle_inferior_event (struct execution_control_state *ecs)
remove_breakpoints ();
registers_changed ();
target_resume (ecs->pid, 1, TARGET_SIGNAL_0); /* Single step */
target_resume (ecs->ptid, 1, TARGET_SIGNAL_0); /* Single step */
ecs->waiton_pid = ecs->pid;
ecs->waiton_ptid = ecs->ptid;
ecs->wp = &(ecs->ws);
ecs->infwait_state = infwait_nonstep_watch_state;
prepare_to_wait (ecs);
@ -2558,7 +2568,7 @@ handle_inferior_event (struct execution_control_state *ecs)
{
#if defined(SOLIB_ADD)
/* Have we reached our destination? If not, keep going. */
if (SOLIB_IN_DYNAMIC_LINKER (ecs->pid, stop_pc))
if (SOLIB_IN_DYNAMIC_LINKER (PIDGET (ecs->ptid), stop_pc))
{
ecs->another_trap = 1;
keep_going (ecs);
@ -3119,26 +3129,26 @@ stop_stepping (struct execution_control_state *ecs)
{
/* Are we stopping for a vfork event? We only stop when we see
the child's event. However, we may not yet have seen the
parent's event. And, inferior_pid is still set to the
parent's event. And, inferior_ptid is still set to the
parent's pid, until we resume again and follow either the
parent or child.
To ensure that we can really touch inferior_pid (aka, the
To ensure that we can really touch inferior_ptid (aka, the
parent process) -- which calls to functions like read_pc
implicitly do -- wait on the parent if necessary. */
if ((pending_follow.kind == TARGET_WAITKIND_VFORKED)
&& !pending_follow.fork_event.saw_parent_fork)
{
int parent_pid;
ptid_t parent_ptid;
do
{
if (target_wait_hook)
parent_pid = target_wait_hook (-1, &(ecs->ws));
parent_ptid = target_wait_hook (pid_to_ptid (-1), &(ecs->ws));
else
parent_pid = target_wait (-1, &(ecs->ws));
parent_ptid = target_wait (pid_to_ptid (-1), &(ecs->ws));
}
while (parent_pid != inferior_pid);
while (! ptid_equal (parent_ptid, inferior_ptid));
}
/* Assuming the inferior still exists, set these up for next
@ -3283,7 +3293,7 @@ prepare_to_wait (struct execution_control_state *ecs)
as part of their normal status mechanism. */
registers_changed ();
ecs->waiton_pid = -1;
ecs->waiton_ptid = pid_to_ptid (-1);
ecs->wp = &(ecs->ws);
}
/* This is the old end of the while loop. Let everybody know we
@ -3433,13 +3443,13 @@ normal_stop (void)
(Note that there's no point in saying anything if the inferior
has exited!) */
if ((previous_inferior_pid != inferior_pid)
if (! ptid_equal (previous_inferior_ptid, inferior_ptid)
&& target_has_execution)
{
target_terminal_ours_for_output ();
printf_filtered ("[Switching to %s]\n",
target_pid_or_tid_to_str (inferior_pid));
previous_inferior_pid = inferior_pid;
target_pid_or_tid_to_str (inferior_ptid));
previous_inferior_ptid = inferior_ptid;
}
/* Make sure that the current_frame's pc is correct. This
@ -3559,7 +3569,8 @@ and/or watchpoints.\n");
#ifdef UI_OUT
if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
ui_out_field_int (uiout, "thread-id", pid_to_thread_id (inferior_pid));
ui_out_field_int (uiout, "thread-id",
pid_to_thread_id (inferior_ptid));
#endif
/* The behavior of this routine with respect to the source
flag is:
@ -3842,7 +3853,7 @@ Are you sure you want to change it? ",
argv++;
}
target_notice_signals (inferior_pid);
target_notice_signals (inferior_ptid);
if (from_tty)
{

View File

@ -47,11 +47,11 @@ extern void _initialize_inftarg (void);
static void child_prepare_to_store (void);
#ifndef CHILD_WAIT
static int child_wait (int, struct target_waitstatus *);
static ptid_t child_wait (ptid_t, struct target_waitstatus *);
#endif /* CHILD_WAIT */
#if !defined(CHILD_POST_WAIT)
void child_post_wait (int, int);
void child_post_wait (ptid_t, int);
#endif
static void child_open (char *, int);
@ -87,7 +87,7 @@ static int child_can_run (void);
static void child_stop (void);
#ifndef CHILD_THREAD_ALIVE
int child_thread_alive (int);
int child_thread_alive (ptid_t);
#endif
static void init_child_ops (void);
@ -116,8 +116,8 @@ int not_same_real_pid = 1;
/* Wait for child to do something. Return pid of child, or -1 in case
of error; store status through argument pointer OURSTATUS. */
static int
child_wait (int pid, struct target_waitstatus *ourstatus)
static ptid_t
child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
int save_errno;
int status;
@ -126,6 +126,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
int related_pid;
int syscall_id;
enum target_waitkind kind;
int pid;
do
{
@ -133,7 +134,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
attached process. */
set_sigio_trap ();
pid = ptrace_wait (inferior_pid, &status);
pid = ptrace_wait (inferior_ptid, &status);
save_errno = errno;
@ -152,7 +153,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
/* Claim it exited with unknown signal. */
ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
return -1;
return pid_to_ptid (-1);
}
/* Did it exit?
@ -163,26 +164,28 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
continue;
}
if (!target_thread_alive (pid))
if (!target_thread_alive (pid_to_ptid (pid)))
{
ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
return pid;
return pid_to_ptid (pid);
}
if (target_has_forked (pid, &related_pid)
&& ((pid == inferior_pid) || (related_pid == inferior_pid)))
&& ((pid == PIDGET (inferior_ptid))
|| (related_pid == PIDGET (inferior_ptid))))
{
ourstatus->kind = TARGET_WAITKIND_FORKED;
ourstatus->value.related_pid = related_pid;
return pid;
return pid_to_ptid (pid);
}
if (target_has_vforked (pid, &related_pid)
&& ((pid == inferior_pid) || (related_pid == inferior_pid)))
&& ((pid == PIDGET (inferior_ptid))
|| (related_pid == PIDGET (inferior_ptid))))
{
ourstatus->kind = TARGET_WAITKIND_VFORKED;
ourstatus->value.related_pid = related_pid;
return pid;
return pid_to_ptid (pid);
}
if (target_has_execd (pid, &execd_pathname))
@ -200,7 +203,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
{
ourstatus->kind = TARGET_WAITKIND_EXECD;
ourstatus->value.execd_pathname = execd_pathname;
return pid;
return pid_to_ptid (pid);
}
}
@ -211,23 +214,23 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
{
ourstatus->kind = kind;
ourstatus->value.syscall_id = syscall_id;
return pid;
return pid_to_ptid (pid);
}
/*## } while (pid != inferior_pid); ## *//* Some other child died or stopped */
/*## } while (pid != PIDGET (inferior_ptid)); ## *//* Some other child died or stopped */
/* hack for thread testing */
}
while ((pid != inferior_pid) && not_same_real_pid);
while ((pid != PIDGET (inferior_ptid)) && not_same_real_pid);
/*## */
store_waitstatus (ourstatus, status);
return pid;
return pid_to_ptid (pid);
}
#endif /* CHILD_WAIT */
#if !defined(CHILD_POST_WAIT)
void
child_post_wait (int pid, int wait_status)
child_post_wait (ptid_t ptid, int wait_status)
{
/* This version of Unix doesn't require a meaningful "post wait"
operation.
@ -244,8 +247,10 @@ child_post_wait (int pid, int wait_status)
for now we're going to try and be compatable with the old thread
code. */
int
child_thread_alive (int pid)
child_thread_alive (ptid_t ptid)
{
pid_t pid = PIDGET (ptid);
return (kill (pid, 0) != -1);
}
@ -280,12 +285,13 @@ child_attach_to_process (char *args, int from_tty, int after_fork)
if (after_fork)
printf_unfiltered ("Attaching after fork to %s\n",
target_pid_to_str (pid));
target_pid_to_str (pid_to_ptid (pid)));
else if (exec_file)
printf_unfiltered ("Attaching to program: %s, %s\n", exec_file,
target_pid_to_str (pid));
target_pid_to_str (pid_to_ptid (pid)));
else
printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
printf_unfiltered ("Attaching to %s\n",
target_pid_to_str (pid_to_ptid (pid)));
gdb_flush (gdb_stdout);
}
@ -295,7 +301,7 @@ child_attach_to_process (char *args, int from_tty, int after_fork)
else
REQUIRE_ATTACH (pid);
inferior_pid = pid;
inferior_ptid = pid_to_ptid (pid);
push_target (&child_ops);
}
#endif /* ATTACH_DETACH */
@ -339,10 +345,10 @@ child_detach_from_process (int pid, char *args, int from_tty, int after_fork)
exec_file = "";
if (after_fork)
printf_unfiltered ("Detaching after fork from %s\n",
target_pid_to_str (pid));
target_pid_to_str (pid_to_ptid (pid)));
else
printf_unfiltered ("Detaching from program: %s, %s\n", exec_file,
target_pid_to_str (pid));
target_pid_to_str (pid_to_ptid (pid)));
gdb_flush (gdb_stdout);
}
if (args)
@ -369,8 +375,8 @@ child_detach_from_process (int pid, char *args, int from_tty, int after_fork)
static void
child_detach (char *args, int from_tty)
{
child_detach_from_process (inferior_pid, args, from_tty, 0);
inferior_pid = 0;
child_detach_from_process (PIDGET (inferior_ptid), args, from_tty, 0);
inferior_ptid = null_ptid;
unpush_target (&child_ops);
}
@ -401,7 +407,7 @@ static void
child_files_info (struct target_ops *ignore)
{
printf_unfiltered ("\tUsing the running image of %s %s.\n",
attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid));
attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid));
}
/* ARGSUSED */
@ -446,10 +452,10 @@ ptrace_him (int pid)
/* On some targets, there must be some explicit actions taken after
the inferior has been started up.
*/
target_post_startup_inferior (pid);
target_post_startup_inferior (pid_to_ptid (pid));
}
/* Start an inferior Unix child process and sets inferior_pid to its pid.
/* Start an inferior Unix child process and sets inferior_ptid to its pid.
EXEC_FILE is the file to run.
ALLARGS is a string containing the arguments to the program.
ENV is the environment vector to pass. Errors reported with error(). */
@ -469,7 +475,7 @@ child_create_inferior (char *exec_file, char *allargs, char **env)
#if !defined(CHILD_POST_STARTUP_INFERIOR)
void
child_post_startup_inferior (int pid)
child_post_startup_inferior (ptid_t ptid)
{
/* This version of Unix doesn't require a meaningful "post startup inferior"
operation by a debugger.
@ -736,9 +742,9 @@ child_core_file_to_sym_file (char *core)
#if !defined(CHILD_PID_TO_STR)
char *
child_pid_to_str (int pid)
child_pid_to_str (ptid_t ptid)
{
return normal_pid_to_str (pid);
return normal_pid_to_str (ptid);
}
#endif

View File

@ -383,7 +383,7 @@ static thread_info_header thread_head =
static thread_info_header deleted_threads =
{0, NULL, NULL};
static saved_real_pid = 0;
static ptid_t saved_real_ptid;
/*************************************************
@ -623,7 +623,7 @@ create_thread_info (int pid, lwpid_t tid)
if (debug_on)
printf ("First thread, pid %d tid %d!\n", pid, tid);
#endif
saved_real_pid = inferior_pid;
saved_real_ptid = inferior_ptid;
}
else
{
@ -1238,7 +1238,7 @@ update_thread_list (void)
for (p = thread_head.head; p; p = p->next)
{
/* Is this an "unseen" thread which really happens to be a process?
If so, is it inferior_pid and is a vfork in flight? If yes to
If so, is it inferior_ptid and is a vfork in flight? If yes to
all, then DON'T REMOVE IT! We're in the midst of moving a vfork
operation, which is a multiple step thing, to the point where we
can touch the parent again. We've most likely stopped to examine
@ -1625,14 +1625,15 @@ call_ttrace (ttreq_t request, int gdb_tid, TTRACE_ARG_TYPE addr,
* in the multi-process future. Use tid as thread,
* probably dooming this to failure. FIX!
*/
if (saved_real_pid != 0)
if (! ptid_equal (saved_real_ptid, null_ptid))
{
#ifdef THREAD_DEBUG
if (debug_on)
printf ("...using saved pid %d\n", saved_real_pid);
printf ("...using saved pid %d\n",
PIDGET (saved_real_ptid));
#endif
real_pid = saved_real_pid;
real_pid = PIDGET (saved_real_ptid);
real_tid = gdb_tid;
}
@ -1653,14 +1654,14 @@ call_ttrace (ttreq_t request, int gdb_tid, TTRACE_ARG_TYPE addr,
if (debug_on)
{
printf ("Translated thread request to process request\n");
if (saved_real_pid == 0)
if (ptid_equal (saved_real_ptid, null_ptid))
printf ("...but there's no saved pid\n");
else
{
if (gdb_tid != saved_real_pid)
if (gdb_tid != PIDGET (saved_real_ptid))
printf ("...but have the wrong pid (%d rather than %d)\n",
gdb_tid, saved_real_pid);
gdb_tid, PIDGET (saved_real_ptid));
}
}
#endif
@ -1747,11 +1748,11 @@ stop_all_threads_of_process (pid_t real_pid)
have its threads examined.
*/
#define CHILD_VFORKED(evt,pid) \
(((evt) == TTEVT_VFORK) && ((pid) != inferior_pid))
(((evt) == TTEVT_VFORK) && ((pid) != PIDGET (inferior_ptid)))
#define CHILD_URPED(evt,pid) \
((((evt) == TTEVT_EXEC) || ((evt) == TTEVT_EXIT)) && ((pid) != vforking_child_pid))
#define PARENT_VFORKED(evt,pid) \
(((evt) == TTEVT_VFORK) && ((pid) == inferior_pid))
(((evt) == TTEVT_VFORK) && ((pid) == PIDGET (inferior_ptid)))
static int
can_touch_threads_of_process (int pid, ttevents_t stopping_event)
@ -2595,8 +2596,8 @@ count_unhandled_events (int real_pid, lwpid_t real_tid)
*
* Note: used by core gdb and so uses the pseudo-pid (really tid).
*/
int
ptrace_wait (int pid, int *status)
ptid_t
ptrace_wait (ptid_t ptid, int *status)
{
ttstate_t tsp;
int ttwait_return;
@ -2620,13 +2621,13 @@ ptrace_wait (int pid, int *status)
if (errno == ESRCH)
{
*status = 0; /* WIFEXITED */
return inferior_pid;
return inferior_ptid;
}
warning ("Call of ttrace_wait returned with errno %d.",
errno);
*status = ttwait_return;
return inferior_pid;
return inferior_ptid;
}
real_pid = tsp.tts_pid;
@ -2688,7 +2689,7 @@ ptrace_wait (int pid, int *status)
#ifdef THREAD_DEBUG
if (debug_on)
printf ("Pid %d has zero'th thread %d; inferior pid is %d\n",
real_pid, real_tid, inferior_pid);
real_pid, real_tid, PIDGET (inferior_ptid));
#endif
add_tthread (real_pid, real_tid);
@ -2851,7 +2852,7 @@ ptrace_wait (int pid, int *status)
* a new thread if for some reason it's never
* seen the main thread before.
*/
inferior_pid = map_to_gdb_tid (real_tid); /* HACK, FIX */
inferior_ptid = pid_to_ptid (map_to_gdb_tid (real_tid)); /* HACK, FIX */
*status = 0 | (tsp.tts_u.tts_exit.tts_exitcode);
}
@ -2904,7 +2905,7 @@ ptrace_wait (int pid, int *status)
/* Remember this for later use in "hppa_prepare_to_proceed".
*/
old_gdb_pid = inferior_pid;
old_gdb_pid = PIDGET (inferior_ptid);
reported_pid = return_pid;
reported_bpt = ((tsp.tts_event & TTEVT_SIGNAL) && (5 == tsp.tts_u.tts_signal.tts_signo));
@ -2913,7 +2914,7 @@ ptrace_wait (int pid, int *status)
warning ("Internal error: process-wait failed.");
}
return return_pid;
return pid_to_ptid (return_pid);
}
@ -3150,9 +3151,9 @@ child_acknowledge_created_inferior (int pid)
* calling require_notification_of_events.
*/
void
child_post_startup_inferior (int real_pid)
child_post_startup_inferior (ptid_t ptid)
{
require_notification_of_events (real_pid);
require_notification_of_events (PIDGET (ptid));
}
/* From here on, we should expect tids rather than pids.
@ -3582,8 +3583,9 @@ child_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
* May need a FIXME for that reason.
*/
int
child_thread_alive (lwpid_t gdb_tid)
child_thread_alive (ptid_t ptid)
{
lwpid_t gdp_tid = PIDGET (ptid);
lwpid_t tid;
/* This spins down the lists twice.
@ -3815,11 +3817,11 @@ kill_inferior (void)
thread_info **paranoia;
int para_count, i;
if (inferior_pid == 0)
if (PIDGET (inferior_ptid) == 0)
return;
/* Walk the list of "threads", some of which are "pseudo threads",
aka "processes". For each that is NOT inferior_pid, stop it,
aka "processes". For each that is NOT inferior_ptid, stop it,
and detach it.
You see, we may not have just a single process to kill. If we're
@ -3849,7 +3851,7 @@ kill_inferior (void)
}
para_count++;
if (t->am_pseudo && (t->pid != inferior_pid))
if (t->am_pseudo && (t->pid != PIDGET (inferior_ptid)))
{
/* TT_PROC_STOP doesn't require a subsequent ttrace_wait, as it
* generates no event.
@ -3872,7 +3874,7 @@ kill_inferior (void)
xfree (paranoia);
call_ttrace (TT_PROC_STOP,
inferior_pid,
PIDGET (inferior_ptid),
TT_NIL,
TT_NIL,
TT_NIL);
@ -4313,7 +4315,7 @@ threads_continue_one_with_signal (lwpid_t gdb_tid, int signal)
* -1 | Step current Continue all threads
* | thread and (but which gets any
* | continue others signal?--We look at
* | "inferior_pid")
* | "inferior_ptid")
* |
* N | Step _this_ thread Continue _this_ thread
* | and leave others and leave others
@ -4323,11 +4325,12 @@ threads_continue_one_with_signal (lwpid_t gdb_tid, int signal)
* | user command.
*/
void
child_resume (lwpid_t gdb_tid, int step, enum target_signal signal)
child_resume (ptid_t ptid, int step, enum target_signal signal)
{
int resume_all_threads;
lwpid_t tid;
process_state_t new_process_state;
lwpid_t gdb_tid = PIDGET (ptid);
resume_all_threads =
(gdb_tid == INFTTRACE_ALL_THREADS) ||
@ -4342,7 +4345,7 @@ child_resume (lwpid_t gdb_tid, int step, enum target_signal signal)
if (vfork_in_flight)
tid = vforking_child_pid;
else
tid = map_from_gdb_tid (inferior_pid);
tid = map_from_gdb_tid (PIDGET (inferior_ptid));
}
else
tid = map_from_gdb_tid (gdb_tid);
@ -4648,7 +4651,7 @@ child_resume (lwpid_t gdb_tid, int step, enum target_signal signal)
/*
* Like it says.
*
* One worry is that we may not be attaching to "inferior_pid"
* One worry is that we may not be attaching to "inferior_ptid"
* and thus may not want to clear out our data. FIXME?
*
*/
@ -4702,7 +4705,7 @@ update_thread_state_after_attach (int pid, attach_continue_t kind_of_go)
*
* We don't need to do mapping here, as we know this
* is the first thread and thus gets the real pid
* (and is "inferior_pid").
* (and is "inferior_ptid").
*
* NOTE: it probably isn't the originating thread,
* but that doesn't matter (we hope!).
@ -4876,7 +4879,7 @@ detach (int signal)
{
errno = 0;
call_ttrace (TT_PROC_DETACH,
inferior_pid,
PIDGET (inferior_ptid),
TT_NIL,
(TTRACE_ARG_TYPE) signal,
TT_NIL);
@ -4939,7 +4942,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
{
/* Need part of initial word -- fetch it. */
buffer[0] = call_ttrace (TT_LWP_RDTEXT,
inferior_pid,
PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) addr,
TT_NIL,
TT_NIL);
@ -4948,7 +4951,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
if (count > 1) /* FIXME, avoid if even boundary */
{
buffer[count - 1] = call_ttrace (TT_LWP_RDTEXT,
inferior_pid,
PIDGET (inferior_ptid),
((TTRACE_ARG_TYPE)
(addr + (count - 1) * sizeof (TTRACE_XFER_TYPE))),
TT_NIL,
@ -4967,7 +4970,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
{
errno = 0;
call_ttrace (TT_LWP_WRDATA,
inferior_pid,
PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) addr,
(TTRACE_ARG_TYPE) buffer[i],
TT_NIL);
@ -4977,7 +4980,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
Gould NP1, at least. */
errno = 0;
call_ttrace (TT_LWP_WRTEXT,
inferior_pid,
PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) addr,
(TTRACE_ARG_TYPE) buffer[i],
TT_NIL);
@ -4993,7 +4996,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
{
errno = 0;
buffer[i] = call_ttrace (TT_LWP_RDTEXT,
inferior_pid,
PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) addr,
TT_NIL,
TT_NIL);
@ -5044,7 +5047,7 @@ udot_info (void)
printf_filtered ("%04x:", udot_off);
}
udot_val = call_ttrace (TT_LWP_RUREGS,
inferior_pid,
PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) udot_off,
TT_NIL,
TT_NIL);
@ -5074,7 +5077,7 @@ child_pid_to_exec_file (int tid)
int name_index;
int i;
int done;
int saved_inferior_pid;
ptid_t saved_inferior_ptid;
/* As of 10.x HP-UX, there's an explicit request to get the
*pathname.
@ -5100,19 +5103,19 @@ child_pid_to_exec_file (int tid)
name_index = 0;
done = 0;
/* On the chance that pid != inferior_pid, set inferior_pid
to pid, so that (grrrr!) implicit uses of inferior_pid get
/* On the chance that pid != inferior_ptid, set inferior_ptid
to pid, so that (grrrr!) implicit uses of inferior_ptid get
the right id.
*/
saved_inferior_pid = inferior_pid;
inferior_pid = tid;
saved_inferior_ptid = inferior_ptid;
inferior_ptid = pid_to_ptid (tid);
/* Try to grab a null-terminated string. */
while (!done)
{
if (target_read_memory (top_of_stack, four_chars, 4) != 0)
{
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return NULL;
}
for (i = 0; i < 4; i++)
@ -5127,11 +5130,11 @@ child_pid_to_exec_file (int tid)
if (exec_file_buffer[0] == '\0')
{
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return NULL;
}
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return exec_file_buffer;
}
@ -5626,17 +5629,18 @@ hppa_range_profitable_for_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len)
char *
hppa_pid_or_tid_to_str (pid_t id)
hppa_pid_or_tid_to_str (ptid_t ptid)
{
static char buf[100]; /* Static because address returned. */
pid_t id = PIDGET (ptid);
/* Does this appear to be a process? If so, print it that way. */
if (is_process_id (id))
return child_pid_to_str (id);
return child_pid_to_str (ptid);
/* Else, print both the GDB thread number and the system thread id. */
sprintf (buf, "thread %d (", pid_to_thread_id (id));
strcat (buf, hppa_tid_to_str (id));
sprintf (buf, "thread %d (", pid_to_thread_id (ptid));
strcat (buf, hppa_tid_to_str (ptid));
strcat (buf, ")\0");
return buf;

View File

@ -1224,7 +1224,7 @@ solib_create_inferior_hook (void)
stop_signal = TARGET_SIGNAL_0;
do
{
target_resume (-1, 0, stop_signal);
target_resume (pid_to_ptid (-1), 0, stop_signal);
wait_for_inferior ();
}
while (stop_signal != TARGET_SIGNAL_TRAP);

View File

@ -73,7 +73,7 @@ struct lwp_info
{
/* The process id of the LWP. This is a combination of the LWP id
and overall process id. */
int pid;
ptid_t ptid;
/* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report
it back yet). */
@ -104,7 +104,8 @@ static int threaded;
#ifndef TIDGET
#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16)
#define PIDGET(PID) (((PID) & 0xffff))
#define PIDGET0(PID) (((PID) & 0xffff))
#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID))
#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16))
#endif
@ -118,7 +119,7 @@ static int threaded;
/* If the last reported event was a SIGTRAP, this variable is set to
the process id of the LWP/thread that got it. */
int trap_pid;
ptid_t trap_ptid;
/* This module's target-specific operations. */
@ -176,17 +177,17 @@ init_lwp_list (void)
Return a pointer to the structure describing the new LWP. */
static struct lwp_info *
add_lwp (int pid)
add_lwp (ptid_t ptid)
{
struct lwp_info *lp;
gdb_assert (is_lwp (pid));
gdb_assert (is_lwp (ptid));
lp = (struct lwp_info *) xmalloc (sizeof (struct lwp_info));
memset (lp, 0, sizeof (struct lwp_info));
lp->pid = pid;
lp->ptid = ptid;
lp->next = lwp_list;
lwp_list = lp;
@ -199,14 +200,14 @@ add_lwp (int pid)
/* Remove the LWP specified by PID from the list. */
static void
delete_lwp (int pid)
delete_lwp (ptid_t ptid)
{
struct lwp_info *lp, *lpprev;
lpprev = NULL;
for (lp = lwp_list; lp; lpprev = lp, lp = lp->next)
if (lp->pid == pid)
if (ptid_equal (lp->ptid, ptid))
break;
if (!lp)
@ -228,15 +229,18 @@ delete_lwp (int pid)
to PID. If no corresponding LWP could be found, return NULL. */
static struct lwp_info *
find_lwp_pid (int pid)
find_lwp_pid (ptid_t ptid)
{
struct lwp_info *lp;
int lwp;
if (is_lwp (pid))
pid = GET_LWP (pid);
if (is_lwp (ptid))
lwp = GET_LWP (ptid);
else
lwp = GET_PID (ptid);
for (lp = lwp_list; lp; lp = lp->next)
if (pid == GET_LWP (lp->pid))
if (lwp == GET_LWP (lp->ptid))
return lp;
return NULL;
@ -263,21 +267,21 @@ iterate_over_lwps (int (*callback) (struct lwp_info *, void *), void *data)
/* Helper functions. */
static void
restore_inferior_pid (void *arg)
restore_inferior_ptid (void *arg)
{
int *saved_pid_ptr = arg;
inferior_pid = *saved_pid_ptr;
ptid_t *saved_ptid_ptr = arg;
inferior_ptid = *saved_ptid_ptr;
xfree (arg);
}
static struct cleanup *
save_inferior_pid (void)
save_inferior_ptid (void)
{
int *saved_pid_ptr;
ptid_t *saved_ptid_ptr;
saved_pid_ptr = xmalloc (sizeof (int));
*saved_pid_ptr = inferior_pid;
return make_cleanup (restore_inferior_pid, saved_pid_ptr);
saved_ptid_ptr = xmalloc (sizeof (ptid_t));
*saved_ptid_ptr = inferior_ptid;
return make_cleanup (restore_inferior_ptid, saved_ptid_ptr);
}
@ -290,7 +294,8 @@ save_inferior_pid (void)
int
lin_lwp_prepare_to_proceed (void)
{
if (trap_pid && inferior_pid != trap_pid)
if (! ptid_equal (trap_ptid, null_ptid)
&& ! ptid_equal (inferior_ptid, trap_ptid))
{
/* Switched over from TRAP_PID. */
CORE_ADDR stop_pc = read_pc ();
@ -298,12 +303,12 @@ lin_lwp_prepare_to_proceed (void)
/* Avoid switching where it wouldn't do any good, i.e. if both
threads are at the same breakpoint. */
trap_pc = read_pc_pid (trap_pid);
trap_pc = read_pc_pid (trap_ptid);
if (trap_pc != stop_pc && breakpoint_here_p (trap_pc))
{
/* User hasn't deleted the breakpoint. Return non-zero, and
switch back to TRAP_PID. */
inferior_pid = trap_pid;
inferior_ptid = trap_ptid;
/* FIXME: Is this stuff really necessary? */
flush_cached_frames ();
@ -330,19 +335,19 @@ lin_lwp_open (char *args, int from_tty)
process. */
void
lin_lwp_attach_lwp (int pid, int verbose)
lin_lwp_attach_lwp (ptid_t ptid, int verbose)
{
struct lwp_info *lp;
gdb_assert (is_lwp (pid));
gdb_assert (is_lwp (ptid));
if (verbose)
printf_filtered ("[New %s]\n", target_pid_to_str (pid));
printf_filtered ("[New %s]\n", target_pid_to_str (ptid));
if (ptrace (PTRACE_ATTACH, GET_LWP (pid), 0, 0) < 0)
error ("Can't attach %s: %s", target_pid_to_str (pid), strerror (errno));
if (ptrace (PTRACE_ATTACH, GET_LWP (ptid), 0, 0) < 0)
error ("Can't attach %s: %s", target_pid_to_str (ptid), strerror (errno));
lp = add_lwp (pid);
lp = add_lwp (ptid);
lp->signalled = 1;
}
@ -375,7 +380,7 @@ find_lwp_callback (struct thread_info *tp, void *data)
{
struct lwp_info *lp = data;
if (tp->private->lwpid == GET_LWP (lp->pid))
if (tp->private->lwpid == GET_LWP (lp->ptid))
return 1;
return 0;
@ -394,7 +399,7 @@ resume_callback (struct lwp_info *lp, void *data)
/* FIXME: kettenis/2000-08-26: This should really be handled
properly by core GDB. */
tp = find_thread_pid (lp->pid);
tp = find_thread_pid (lp->ptid);
if (tp == NULL)
tp = iterate_over_threads (find_lwp_callback, lp);
gdb_assert (tp);
@ -411,7 +416,7 @@ resume_callback (struct lwp_info *lp, void *data)
}
#endif
child_resume (GET_LWP (lp->pid), 0, TARGET_SIGNAL_0);
child_resume (pid_to_ptid (GET_LWP (lp->ptid)), 0, TARGET_SIGNAL_0);
lp->stopped = 0;
lp->step = 0;
}
@ -420,7 +425,7 @@ resume_callback (struct lwp_info *lp, void *data)
}
static void
lin_lwp_resume (int pid, int step, enum target_signal signo)
lin_lwp_resume (ptid_t ptid, int step, enum target_signal signo)
{
struct lwp_info *lp;
int resume_all;
@ -429,17 +434,17 @@ lin_lwp_resume (int pid, int step, enum target_signal signo)
STEP is non-zero, a specific PID means `step only this process
id'. But if STEP is zero, then PID means `continue *all*
processes, but give the signal only to this one'. */
resume_all = (pid == -1) || !step;
resume_all = (PIDGET (ptid) == -1) || !step;
/* If PID is -1, it's the current inferior that should be
handled special. */
if (pid == -1)
pid = inferior_pid;
if (PIDGET (ptid) == -1)
ptid = inferior_ptid;
lp = find_lwp_pid (pid);
lp = find_lwp_pid (ptid);
if (lp)
{
pid = GET_LWP (lp->pid);
ptid = pid_to_ptid (GET_LWP (lp->ptid));
/* Remember if we're stepping. */
lp->step = step;
@ -462,7 +467,7 @@ lin_lwp_resume (int pid, int step, enum target_signal signo)
if (resume_all)
iterate_over_lwps (resume_callback, NULL);
child_resume (pid, step, signo);
child_resume (ptid, step, signo);
}
@ -475,7 +480,7 @@ stop_callback (struct lwp_info *lp, void *data)
{
int ret;
ret = kill (GET_LWP (lp->pid), SIGSTOP);
ret = kill (GET_LWP (lp->ptid), SIGSTOP);
gdb_assert (ret == 0);
lp->signalled = 1;
@ -497,33 +502,33 @@ stop_wait_callback (struct lwp_info *lp, void *data)
gdb_assert (lp->status == 0);
pid = waitpid (GET_LWP (lp->pid), &status,
is_cloned (lp->pid) ? __WCLONE : 0);
pid = waitpid (GET_LWP (lp->ptid), &status,
is_cloned (lp->ptid) ? __WCLONE : 0);
if (pid == -1 && errno == ECHILD)
/* OK, the proccess has disappeared. We'll catch the actual
exit event in lin_lwp_wait. */
return 0;
gdb_assert (pid == GET_LWP (lp->pid));
gdb_assert (pid == GET_LWP (lp->ptid));
if (WIFEXITED (status) || WIFSIGNALED (status))
{
gdb_assert (num_lwps > 1);
if (in_thread_list (lp->pid))
if (in_thread_list (lp->ptid))
{
/* Core GDB cannot deal with us deleting the current
thread. */
if (lp->pid != inferior_pid)
delete_thread (lp->pid);
if (!ptid_equal (lp->ptid, inferior_ptid))
delete_thread (lp->ptid);
printf_unfiltered ("[%s exited]\n",
target_pid_to_str (lp->pid));
target_pid_to_str (lp->ptid));
}
if (debug_lin_lwp)
fprintf_unfiltered (gdb_stdlog,
"%s exited.\n", target_pid_to_str (lp->pid));
"%s exited.\n", target_pid_to_str (lp->ptid));
delete_lwp (lp->pid);
delete_lwp (lp->ptid);
return 0;
}
@ -533,7 +538,7 @@ stop_wait_callback (struct lwp_info *lp, void *data)
if (WSTOPSIG (status) != SIGSTOP)
{
if (WSTOPSIG (status) == SIGTRAP
&& breakpoint_inserted_here_p (read_pc_pid (pid)
&& breakpoint_inserted_here_p (read_pc_pid (pid_to_ptid (pid))
- DECR_PC_AFTER_BREAK))
{
/* If a LWP other than the LWP that we're reporting an
@ -553,11 +558,13 @@ stop_wait_callback (struct lwp_info *lp, void *data)
fprintf_unfiltered (gdb_stdlog,
"Tripped breakpoint at %lx in LWP %d"
" while waiting for SIGSTOP.\n",
(long) read_pc_pid (lp->pid), pid);
(long) read_pc_pid (lp->ptid), pid);
/* Set the PC to before the trap. */
if (DECR_PC_AFTER_BREAK)
write_pc_pid (read_pc_pid (pid) - DECR_PC_AFTER_BREAK, pid);
write_pc_pid (read_pc_pid (pid_to_ptid (pid))
- DECR_PC_AFTER_BREAK,
pid_to_ptid (pid));
}
else
{
@ -599,12 +606,13 @@ running_callback (struct lwp_info *lp, void *data)
return (lp->stopped == 0);
}
static int
lin_lwp_wait (int pid, struct target_waitstatus *ourstatus)
static ptid_t
lin_lwp_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
struct lwp_info *lp = NULL;
int options = 0;
int status = 0;
pid_t pid = PIDGET (ptid);
/* Make sure SIGCHLD is blocked. */
if (! sigismember (&blocked_mask, SIGCHLD))
@ -625,7 +633,7 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus)
if (debug_lin_lwp)
fprintf_unfiltered (gdb_stdlog,
"Using pending wait status for LWP %d.\n",
GET_LWP (lp->pid));
(int) GET_LWP (lp->ptid));
status = lp->status;
lp->status = 0;
@ -636,14 +644,15 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus)
processes. */
options = __WCLONE | WNOHANG;
}
else if (is_lwp (pid))
else if (is_lwp (ptid))
{
if (debug_lin_lwp)
fprintf_unfiltered (gdb_stdlog,
"Waiting for specific LWP %d.\n", GET_LWP (pid));
"Waiting for specific LWP %d.\n",
(int) GET_LWP (ptid));
/* We have a specific LWP to check. */
lp = find_lwp_pid (GET_LWP (pid));
lp = find_lwp_pid (ptid);
gdb_assert (lp);
status = lp->status;
lp->status = 0;
@ -652,13 +661,13 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus)
if (status)
fprintf_unfiltered (gdb_stdlog,
"Using pending wait status for LWP %d.\n",
GET_LWP (lp->pid));
GET_LWP (lp->ptid));
/* If we have to wait, take into account whether PID is a cloned
process or not. And we have to convert it to something that
the layer beneath us can understand. */
options = is_cloned (lp->pid) ? __WCLONE : 0;
pid = GET_LWP (pid);
options = is_cloned (lp->ptid) ? __WCLONE : 0;
pid = GET_LWP (ptid);
}
if (status && lp->signalled)
@ -674,7 +683,8 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus)
/* Resume the thread. It should halt immediately returning the
pending SIGSTOP. */
child_resume (GET_LWP (lp->pid), lp->step, TARGET_SIGNAL_0);
child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step,
TARGET_SIGNAL_0);
lp->stopped = 0;
/* This should catch the pending SIGSTOP. */
@ -694,25 +704,26 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus)
{
gdb_assert (pid == -1 || lwpid == pid);
lp = find_lwp_pid (lwpid);
lp = find_lwp_pid (pid_to_ptid (lwpid));
if (! lp)
{
lp = add_lwp (BUILD_LWP (lwpid, inferior_pid));
lp = add_lwp (BUILD_LWP (lwpid, GET_PID (inferior_ptid)));
if (threaded)
{
gdb_assert (WIFSTOPPED (status)
&& WSTOPSIG (status) == SIGSTOP);
lp->signalled = 1;
if (! in_thread_list (inferior_pid))
if (! in_thread_list (inferior_ptid))
{
inferior_pid = BUILD_LWP (inferior_pid, inferior_pid);
add_thread (inferior_pid);
inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid),
GET_PID (inferior_ptid));
add_thread (inferior_ptid);
}
add_thread (lp->pid);
add_thread (lp->ptid);
printf_unfiltered ("[New %s]\n",
target_pid_to_str (lp->pid));
target_pid_to_str (lp->ptid));
}
}
@ -721,21 +732,21 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus)
left in the process. */
if ((WIFEXITED (status) || WIFSIGNALED (status)) && num_lwps > 1)
{
if (in_thread_list (lp->pid))
if (in_thread_list (lp->ptid))
{
/* Core GDB cannot deal with us deleting the current
thread. */
if (lp->pid != inferior_pid)
delete_thread (lp->pid);
if (! ptid_equal (lp->ptid, inferior_ptid))
delete_thread (lp->ptid);
printf_unfiltered ("[%s exited]\n",
target_pid_to_str (lp->pid));
target_pid_to_str (lp->ptid));
}
if (debug_lin_lwp)
fprintf_unfiltered (gdb_stdlog,
"%s exited.\n",
target_pid_to_str (lp->pid));
target_pid_to_str (lp->ptid));
delete_lwp (lp->pid);
delete_lwp (lp->ptid);
/* Make sure there is at least one thread running. */
gdb_assert (iterate_over_lwps (running_callback, NULL));
@ -753,12 +764,13 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus)
if (debug_lin_lwp)
fprintf_unfiltered (gdb_stdlog,
"Delayed SIGSTOP caught for %s.\n",
target_pid_to_str (lp->pid));
target_pid_to_str (lp->ptid));
/* This is a delayed SIGSTOP. */
lp->signalled = 0;
child_resume (GET_LWP (lp->pid), lp->step, TARGET_SIGNAL_0);
child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step,
TARGET_SIGNAL_0);
lp->stopped = 0;
/* Discard the event. */
@ -803,7 +815,7 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus)
&& signal_print_state (signo) == 0
&& signal_pass_state (signo) == 1)
{
child_resume (GET_LWP (lp->pid), lp->step, signo);
child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step, signo);
lp->stopped = 0;
status = 0;
goto retry;
@ -824,18 +836,18 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus)
process id. */
if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP)
trap_pid = (threaded ? lp->pid : GET_LWP (lp->pid));
trap_ptid = (threaded ? lp->ptid : pid_to_ptid (GET_LWP (lp->ptid)));
else
trap_pid = 0;
trap_ptid = null_ptid;
store_waitstatus (ourstatus, status);
return (threaded ? lp->pid : GET_LWP (lp->pid));
return (threaded ? lp->ptid : pid_to_ptid (GET_LWP (lp->ptid)));
}
static int
kill_callback (struct lwp_info *lp, void *data)
{
ptrace (PTRACE_KILL, GET_LWP (lp->pid), 0, 0);
ptrace (PTRACE_KILL, GET_LWP (lp->ptid), 0, 0);
return 0;
}
@ -851,22 +863,22 @@ kill_wait_callback (struct lwp_info *lp, void *data)
/* For cloned processes we must check both with __WCLONE and
without, since the exit status of a cloned process isn't reported
with __WCLONE. */
if (is_cloned (lp->pid))
if (is_cloned (lp->ptid))
{
do
{
pid = waitpid (GET_LWP (lp->pid), NULL, __WCLONE);
pid = waitpid (GET_LWP (lp->ptid), NULL, __WCLONE);
}
while (pid == GET_LWP (lp->pid));
while (pid == GET_LWP (lp->ptid));
gdb_assert (pid == -1 && errno == ECHILD);
}
do
{
pid = waitpid (GET_LWP (lp->pid), NULL, 0);
pid = waitpid (GET_LWP (lp->ptid), NULL, 0);
}
while (pid == GET_LWP (lp->pid));
while (pid == GET_LWP (lp->ptid));
gdb_assert (pid == -1 && errno == ECHILD);
return 0;
@ -906,7 +918,7 @@ lin_lwp_mourn_inferior (void)
init_lwp_list ();
trap_pid = 0;
trap_ptid = null_ptid;
/* Restore the original signal mask. */
sigprocmask (SIG_SETMASK, &normal_mask, NULL);
@ -923,10 +935,10 @@ lin_lwp_mourn_inferior (void)
static void
lin_lwp_fetch_registers (int regno)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
if (is_lwp (inferior_pid))
inferior_pid = GET_LWP (inferior_pid);
if (is_lwp (inferior_ptid))
inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid));
fetch_inferior_registers (regno);
@ -936,10 +948,10 @@ lin_lwp_fetch_registers (int regno)
static void
lin_lwp_store_registers (int regno)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
if (is_lwp (inferior_pid))
inferior_pid = GET_LWP (inferior_pid);
if (is_lwp (inferior_ptid))
inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid));
store_inferior_registers (regno);
@ -951,11 +963,11 @@ lin_lwp_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
struct mem_attrib *attrib,
struct target_ops *target)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
int xfer;
if (is_lwp (inferior_pid))
inferior_pid = GET_LWP (inferior_pid);
if (is_lwp (inferior_ptid))
inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid));
xfer = child_xfer_memory (memaddr, myaddr, len, write, attrib, target);
@ -964,12 +976,12 @@ lin_lwp_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
}
static int
lin_lwp_thread_alive (int pid)
lin_lwp_thread_alive (ptid_t ptid)
{
gdb_assert (is_lwp (pid));
gdb_assert (is_lwp (ptid));
errno = 0;
ptrace (PTRACE_PEEKUSER, GET_LWP (pid), 0, 0);
ptrace (PTRACE_PEEKUSER, GET_LWP (ptid), 0, 0);
if (errno)
return 0;
@ -977,17 +989,17 @@ lin_lwp_thread_alive (int pid)
}
static char *
lin_lwp_pid_to_str (int pid)
lin_lwp_pid_to_str (ptid_t ptid)
{
static char buf[64];
if (is_lwp (pid))
if (is_lwp (ptid))
{
snprintf (buf, sizeof (buf), "LWP %d", GET_LWP (pid));
snprintf (buf, sizeof (buf), "LWP %ld", GET_LWP (ptid));
return buf;
}
return normal_pid_to_str (pid);
return normal_pid_to_str (ptid);
}
static void

View File

@ -127,11 +127,12 @@
#ifndef TIDGET
#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16)
#define PIDGET(PID) (((PID) & 0xffff))
#define PIDGET0(PID) (((PID) & 0xffff))
#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID))
#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16))
#endif
/* Macros for superimposing PID and TID into inferior_pid. */
/* Macros for superimposing PID and TID into inferior_ptid. */
#define THREAD_FLAG 0x80000000
#define is_thread(ARG) (((ARG) & THREAD_FLAG) != 0)
#define is_lwp(ARG) (((ARG) & THREAD_FLAG) == 0)
@ -303,8 +304,8 @@ ps_ptwrite (gdb_ps_prochandle_t ph, /* write to text segment */
return rw_common (ph, addr, (char *) buf, size, PS_WRITE);
}
static struct cleanup *save_inferior_pid (void);
static void restore_inferior_pid (void *saved_pid);
static struct cleanup *save_inferior_ptid (void);
static void restore_inferior_ptid (void *saved_pid);
static char *thr_err_string (td_err_e);
static char *thr_state_string (td_thr_state_e);
@ -315,10 +316,9 @@ td_thragent_t * main_threadagent;
* Common proc_service routine for reading and writing memory.
*/
/* FIXME: once we've munged the inferior_pid, why can't we
/* FIXME: once we've munged the inferior_ptid, why can't we
simply call target_read/write_memory and return? */
static ps_err_e
rw_common (const struct ps_prochandle *ph,
paddr_t addr,
@ -326,11 +326,11 @@ rw_common (const struct ps_prochandle *ph,
int size,
int write_p)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
int to_do = size;
int done = 0;
inferior_pid = main_prochandle.pid;
inferior_ptid = pid_to_ptid (main_prochandle.pid);
while (to_do > 0)
{
@ -353,19 +353,19 @@ rw_common (const struct ps_prochandle *ph,
}
/* Cleanup functions used by the register callbacks
(which have to manipulate the global inferior_pid). */
(which have to manipulate the global inferior_ptid). */
ps_err_e
ps_lgetregs (gdb_ps_prochandle_t ph, /* Get LWP general regs */
lwpid_t lwpid,
prgregset_t gregset)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
inferior_pid = BUILD_LWP (lwpid, main_prochandle.pid);
inferior_ptid = BUILD_LWP (lwpid, main_prochandle.pid);
current_target.to_fetch_registers (-1);
fill_gregset (gregset, -1);
fill_gregset ((gdb_gregset_t *) gregset, -1);
do_cleanups (old_chain);
return PS_OK;
@ -376,10 +376,10 @@ ps_lsetregs (gdb_ps_prochandle_t ph, /* Set LWP general regs */
lwpid_t lwpid,
const prgregset_t gregset)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
inferior_pid = BUILD_LWP (lwpid, main_prochandle.pid);
supply_gregset (gregset);
inferior_ptid = BUILD_LWP (lwpid, main_prochandle.pid);
supply_gregset ((gdb_gregset_t *) gregset);
current_target.to_store_registers (-1);
do_cleanups (old_chain);
return PS_OK;
@ -390,9 +390,9 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, /* Get LWP float regs */
lwpid_t lwpid,
gdb_prfpregset_t *fpregset)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
inferior_pid = BUILD_LWP (lwpid, main_prochandle.pid);
inferior_ptid = BUILD_LWP (lwpid, main_prochandle.pid);
current_target.to_fetch_registers (-1);
fill_fpregset (fpregset, -1);
do_cleanups (old_chain);
@ -404,9 +404,9 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, /* Set LWP float regs */
lwpid_t lwpid,
const gdb_prfpregset_t *fpregset)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
inferior_pid = BUILD_LWP (lwpid, main_prochandle.pid);
inferior_ptid = BUILD_LWP (lwpid, main_prochandle.pid);
supply_fpregset (fpregset);
current_target.to_store_registers (-1);
do_cleanups (old_chain);
@ -628,44 +628,44 @@ init_thread_db_library (void)
LOCAL FUNCTION
save_inferior_pid - Save inferior_pid on the cleanup list
restore_inferior_pid - Restore inferior_pid from the cleanup list
save_inferior_ptid - Save inferior_ptid on the cleanup list
restore_inferior_ptid - Restore inferior_ptid from the cleanup list
SYNOPSIS
struct cleanup *save_inferior_pid (void);
void restore_inferior_pid (void *saved_pid);
struct cleanup *save_inferior_ptid (void);
void restore_inferior_ptid (void *saved_pid);
DESCRIPTION
These two functions act in unison to restore inferior_pid in
These two functions act in unison to restore inferior_ptid in
case of an error.
NOTES
inferior_pid is a global variable that needs to be changed by many
inferior_ptid is a global variable that needs to be changed by many
of these routines before calling functions in procfs.c. In order
to guarantee that inferior_pid gets restored (in case of errors),
you need to call save_inferior_pid before changing it. At the end
to guarantee that inferior_ptid gets restored (in case of errors),
you need to call save_inferior_ptid before changing it. At the end
of the function, you should invoke do_cleanups to restore it.
*/
static struct cleanup *
save_inferior_pid (void)
save_inferior_ptid (void)
{
int *saved_pid_ptr;
ptid_t *saved_ptid_ptr;
saved_pid_ptr = xmalloc (sizeof (int));
*saved_pid_ptr = inferior_pid;
return make_cleanup (restore_inferior_pid, saved_pid_ptr);
saved_ptid_ptr = xmalloc (sizeof (ptid_t));
*saved_ptid_ptr = inferior_ptid;
return make_cleanup (restore_inferior_ptid, saved_ptid_ptr);
}
static void
restore_inferior_pid (void *arg)
restore_inferior_ptid (void *arg)
{
int *saved_pid_ptr = arg;
inferior_pid = *saved_pid_ptr;
ptid_t *saved_ptid_ptr = arg;
inferior_ptid = *saved_ptid_ptr;
xfree (arg);
}
@ -920,10 +920,10 @@ enable_thread_event_reporting (td_thragent_t *ta)
}
/* Set up the breakpoint. */
create_thread_event_breakpoint (notify.u.bptaddr);
create_thread_event_breakpoint ((CORE_ADDR) notify.u.bptaddr);
/* Save it's location. */
thread_creation_bkpt_address = notify.u.bptaddr;
thread_creation_bkpt_address = (CORE_ADDR) notify.u.bptaddr;
/* thread death */
/* get breakpoint location */
@ -933,10 +933,10 @@ enable_thread_event_reporting (td_thragent_t *ta)
return;
}
/* Set up the breakpoint. */
create_thread_event_breakpoint (notify.u.bptaddr);
create_thread_event_breakpoint ((CORE_ADDR) notify.u.bptaddr);
/* Save it's location. */
thread_death_bkpt_address = notify.u.bptaddr;
thread_death_bkpt_address = (CORE_ADDR) notify.u.bptaddr;
}
/* This function handles the global parts of disabling thread events.
@ -969,6 +969,7 @@ check_for_thread_event (struct target_waitstatus *tws, int event_pid)
{
/* FIXME: to be more efficient, we should keep a static
list of threads, and update it only here (with td_ta_thr_iter). */
return 0;
}
static void
@ -1044,7 +1045,7 @@ thread_db_new_objfile (struct objfile *objfile)
goto quit; /* un-interesting object file */
/* Initialize our "main prochandle" with the main inferior pid. */
main_prochandle.pid = PIDGET (inferior_pid);
main_prochandle.pid = PIDGET (inferior_ptid);
/* Now attempt to open a thread_db connection to the
thread library running in the child process. */
@ -1058,7 +1059,7 @@ thread_db_new_objfile (struct objfile *objfile)
break;
case TD_OK: /* libthread detected in child: we go live now! */
thread_db_push_target ();
event_pid = inferior_pid; /* for resume */
event_pid = PIDGET (inferior_ptid); /* for resume */
/* Now stop everyone else, and attach any new threads you find. */
p_td_ta_thr_iter (main_threadagent,
@ -1105,14 +1106,14 @@ quit:
*/
static int
thread_db_alive (int pid)
thread_db_alive (ptid_t ptid)
{
if (is_thread (pid)) /* user-space (non-kernel) thread */
if (is_thread (ptid)) /* user-space (non-kernel) thread */
{
td_thrhandle_t th;
td_err_e ret;
int pid = GET_THREAD (ptid);
pid = GET_THREAD (pid);
if ((ret = p_td_ta_map_id2thr (main_threadagent, pid, &th)) != TD_OK)
return 0; /* thread not found */
if ((ret = p_td_thr_validate (&th)) != TD_OK)
@ -1120,7 +1121,7 @@ thread_db_alive (int pid)
return 1; /* known thread: return true */
}
else if (target_beneath->to_thread_alive)
return target_beneath->to_thread_alive (pid);
return target_beneath->to_thread_alive (ptid);
else
return 0; /* default to "not alive" (shouldn't happen anyway) */
}
@ -1166,17 +1167,17 @@ get_lwp_from_thread_id (int tid /* thread_t? */)
*/
static char *
thread_db_pid_to_str (int pid)
thread_db_pid_to_str (ptid_t ptid)
{
static char buf[100];
td_thrhandle_t th;
td_thrinfo_t ti;
td_err_e ret;
if (is_thread (pid))
if (is_thread (ptid))
{
if ((ret = p_td_ta_map_id2thr (main_threadagent,
GET_THREAD (pid),
GET_THREAD (ptid),
&th)) != TD_OK)
error ("thread_db: map_id2thr failed: %s", thr_err_string (ret));
@ -1185,14 +1186,14 @@ thread_db_pid_to_str (int pid)
if (ti.ti_state == TD_THR_ACTIVE &&
ti.ti_lid != 0)
sprintf (buf, "Thread %d (LWP %d)", ti.ti_tid, ti.ti_lid);
sprintf (buf, "Thread %ld (LWP %d)", ti.ti_tid, ti.ti_lid);
else
sprintf (buf, "Thread %d (%s)", ti.ti_tid,
sprintf (buf, "Thread %ld (%s)", ti.ti_tid,
thr_state_string (ti.ti_state));
}
else if (GET_LWP (pid))
sprintf (buf, "LWP %d", GET_LWP (pid));
else return normal_pid_to_str (pid);
else if (GET_LWP (ptid))
sprintf (buf, "LWP %ld", GET_LWP (ptid));
else return normal_pid_to_str (ptid);
return buf;
}
@ -1210,7 +1211,7 @@ thread_db_files_info (struct target_ops *tgt_vector)
}
/*
* xfer_memory has to munge the inferior_pid before passing the call
* xfer_memory has to munge the inferior_ptid before passing the call
* down to the target layer.
*/
@ -1222,14 +1223,14 @@ thread_db_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int dowrite,
struct cleanup *old_chain;
int ret;
old_chain = save_inferior_pid ();
old_chain = save_inferior_ptid ();
if (is_thread (inferior_pid) ||
!target_thread_alive (inferior_pid))
if (is_thread (inferior_ptid) ||
!target_thread_alive (inferior_ptid))
{
/* FIXME: use the LID/LWP, so that underlying process layer
can read memory from specific threads? */
inferior_pid = main_prochandle.pid;
inferior_ptid = pid_to_ptid (main_prochandle.pid);
}
ret = target_beneath->to_xfer_memory (memaddr, myaddr, len,
@ -1239,7 +1240,7 @@ thread_db_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int dowrite,
}
/*
* fetch_registers has to determine if inferior_pid is a user-space thread.
* fetch_registers has to determine if inferior_ptid is a user-space thread.
* If so, we use the thread_db API to get the registers.
* And if not, we call the underlying process stratum.
*/
@ -1253,15 +1254,15 @@ thread_db_fetch_registers (int regno)
thread_t thread;
td_err_e ret;
if (!is_thread (inferior_pid)) /* kernel thread */
if (!is_thread (inferior_ptid)) /* kernel thread */
{ /* pass the request on to the target underneath. */
target_beneath->to_fetch_registers (regno);
return;
}
/* convert inferior_pid into a td_thrhandle_t */
/* convert inferior_ptid into a td_thrhandle_t */
if ((thread = GET_THREAD (inferior_pid)) == 0)
if ((thread = GET_THREAD (inferior_ptid)) == 0)
error ("fetch_registers: thread == 0");
if ((ret = p_td_ta_map_id2thr (main_threadagent, thread, &thandle)) != TD_OK)
@ -1283,13 +1284,13 @@ thread_db_fetch_registers (int regno)
because the td routines call ps_lget* which affect the values stored in the
registers array. */
supply_gregset (gregset);
supply_gregset ((gdb_gregset_t *) gregset);
supply_fpregset (&fpregset);
}
/*
* store_registers has to determine if inferior_pid is a user-space thread.
* store_registers has to determine if inferior_ptid is a user-space thread.
* If so, we use the thread_db API to get the registers.
* And if not, we call the underlying process stratum.
*/
@ -1303,15 +1304,15 @@ thread_db_store_registers (int regno)
thread_t thread;
td_err_e ret;
if (!is_thread (inferior_pid)) /* Kernel thread: */
if (!is_thread (inferior_ptid)) /* Kernel thread: */
{ /* pass the request on to the underlying target vector. */
target_beneath->to_store_registers (regno);
return;
}
/* convert inferior_pid into a td_thrhandle_t */
/* convert inferior_ptid into a td_thrhandle_t */
if ((thread = GET_THREAD (inferior_pid)) == 0)
if ((thread = GET_THREAD (inferior_ptid)) == 0)
error ("store_registers: thread == 0");
if ((ret = p_td_ta_map_id2thr (main_threadagent, thread, &thandle)) != TD_OK)
@ -1335,7 +1336,7 @@ thread_db_store_registers (int regno)
}
fill_gregset (gregset, regno);
fill_gregset ((gdb_gregset_t *) gregset, regno);
fill_fpregset (&fpregset, regno);
if ((ret = p_td_thr_setgregs (&thandle, gregset)) != TD_OK)
@ -1350,12 +1351,12 @@ handle_new_thread (int tid, /* user thread id */
int lid, /* kernel thread id */
int verbose)
{
int gdb_pid = BUILD_THREAD (tid, main_prochandle.pid);
ptid_t gdb_ptid = BUILD_THREAD (tid, main_prochandle.pid);
int wait_pid, wait_status;
if (verbose)
printf_filtered ("[New %s]\n", target_pid_to_str (gdb_pid));
add_thread (gdb_pid);
printf_filtered ("[New %s]\n", target_pid_to_str (gdb_ptid));
add_thread (gdb_ptid);
if (lid != main_prochandle.pid)
{
@ -1408,7 +1409,7 @@ find_new_threads_callback (const td_thrhandle_t *th, void *ignored)
static void
thread_db_find_new_threads (void)
{
if (inferior_pid == -1) /* FIXME: still necessary? */
if (PIDGET (inferior_ptid) == -1) /* FIXME: still necessary? */
{
printf_filtered ("No process.\n");
return;
@ -1427,7 +1428,7 @@ thread_db_find_new_threads (void)
/*
* Resume all threads, or resume a single thread.
* If step is true, then single-step the appropriate thread
* (or single-step inferior_pid, but continue everyone else).
* (or single-step inferior_ptid, but continue everyone else).
* If signo is true, then send that signal to at least one thread.
*/
@ -1467,7 +1468,7 @@ resume_thread_callback (const td_thrhandle_t *th, void *data)
/* Unconditionally continue the thread with no signal.
Only the event thread will get a signal of any kind. */
target_beneath->to_resume (ti.ti_lid, 0, 0);
target_beneath->to_resume (pid_to_ptid (ti.ti_lid), 0, 0);
}
return 0;
}
@ -1480,7 +1481,7 @@ new_resume_thread_callback (threadinfo *thread, void *data)
{
/* Unconditionally continue the thread with no signal (for now). */
target_beneath->to_resume (thread->lid, 0, 0);
target_beneath->to_resume (pid_to_ptid (thread->lid), 0, 0);
}
return 0;
}
@ -1490,29 +1491,29 @@ static int last_resume_step;
static int last_resume_signo;
static void
thread_db_resume (int pid, int step, enum target_signal signo)
thread_db_resume (ptid_t ptid, int step, enum target_signal signo)
{
last_resume_pid = pid;
last_resume_pid = PIDGET (ptid);
last_resume_step = step;
last_resume_signo = signo;
/* resuming a specific pid? */
if (pid != -1)
if (PIDGET (ptid) != -1)
{
if (is_thread (pid))
pid = get_lwp_from_thread_id (GET_THREAD (pid));
else if (GET_LWP (pid))
pid = GET_LWP (pid);
if (is_thread (ptid))
ptid = pid_to_ptid (get_lwp_from_thread_id (GET_THREAD (ptid)));
else if (GET_LWP (ptid))
ptid = pid_to_ptid (GET_LWP (ptid));
}
/* Apparently the interpretation of 'pid' is dependent on 'step':
If step is true, then a specific pid means 'step only this pid'.
But if step is not true, then pid means 'continue ALL pids, but
give the signal only to this one'. */
if (pid != -1 && step)
if (PIDGET (ptid) != -1 && step)
{
/* FIXME: is this gonna work in all circumstances? */
target_beneath->to_resume (pid, step, signo);
target_beneath->to_resume (ptid, step, signo);
}
else
{
@ -1529,11 +1530,11 @@ thread_db_resume (int pid, int step, enum target_signal signo)
/* now resume event thread, and if necessary also main thread. */
if (event_pid)
{
target_beneath->to_resume (event_pid, step, signo);
target_beneath->to_resume (pid_to_ptid (event_pid), step, signo);
}
if (event_pid != main_prochandle.pid)
{
target_beneath->to_resume (main_prochandle.pid, 0, 0);
target_beneath->to_resume (pid_to_ptid (main_prochandle.pid), 0, 0);
}
}
}
@ -1546,7 +1547,7 @@ stop_or_attach_thread_callback (const td_thrhandle_t *th, void *data)
{
td_thrinfo_t ti;
td_err_e ret;
int gdb_pid;
ptid_t gdb_ptid;
int on_off = 1;
if ((ret = p_td_thr_get_info (th, &ti)) != TD_OK)
@ -1559,8 +1560,8 @@ stop_or_attach_thread_callback (const td_thrhandle_t *th, void *data)
We build this list anew at every wait event. */
insert_thread (ti.ti_tid, ti.ti_lid, ti.ti_state, ti.ti_type);
/* Now: if we've already seen it, stop it, else add it and attach it. */
gdb_pid = BUILD_THREAD (ti.ti_tid, main_prochandle.pid);
if (!in_thread_list (gdb_pid)) /* new thread */
gdb_ptid = BUILD_THREAD (ti.ti_tid, main_prochandle.pid);
if (!in_thread_list (gdb_ptid)) /* new thread */
{
handle_new_thread (ti.ti_tid, ti.ti_lid, 1);
/* Enable thread events */
@ -1655,13 +1656,14 @@ wait_for_stop (int pid)
if (retpid != event_pid &&
signo == SIGTRAP &&
breakpoint_inserted_here_p (read_pc_pid (retpid) -
breakpoint_inserted_here_p (read_pc_pid (pid_to_ptid (retpid)) -
DECR_PC_AFTER_BREAK))
{
/* Set the pc to before the trap and DO NOT re-send the signal */
if (DECR_PC_AFTER_BREAK)
write_pc_pid (read_pc_pid (retpid) - DECR_PC_AFTER_BREAK,
retpid);
write_pc_pid (read_pc_pid (pid_to_ptid (retpid))
- DECR_PC_AFTER_BREAK,
pid_to_ptid (retpid));
}
/* Since SIGINT gets forwarded to the entire process group
@ -1676,7 +1678,7 @@ wait_for_stop (int pid)
{
wstatus [signo] = 1;
}
child_resume (retpid, 0, TARGET_SIGNAL_0);
child_resume (pid_to_ptid (retpid), 0, TARGET_SIGNAL_0);
continue;
}
@ -1732,14 +1734,15 @@ new_wait_thread_callback (threadinfo *thread, void *data)
* user-space thread.
*/
static int
thread_db_wait (int pid, struct target_waitstatus *ourstatus)
static ptid_t
thread_db_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
td_thrhandle_t thandle;
td_thrinfo_t ti;
td_err_e ret;
lwpid_t lwp;
int retpid;
ptid_t retptid;
int status;
int save_errno;
@ -1753,10 +1756,10 @@ thread_db_wait (int pid, struct target_waitstatus *ourstatus)
/* FIXME: should I do the wait right here inline? */
#if 0
if (pid == -1)
if (PIDGET (ptid) == -1)
lwp = -1;
else
lwp = get_lwp_from_thread_id (GET_THREAD (pid));
lwp = get_lwp_from_thread_id (GET_THREAD (ptid));
#endif
@ -1767,7 +1770,7 @@ thread_db_wait (int pid, struct target_waitstatus *ourstatus)
FIXME: do I have any killing to do?
Can I get this event mistakenly from a thread? */
if (ourstatus->kind == TARGET_WAITKIND_EXITED)
return retpid;
return pid_to_ptid (retpid);
/* OK, we got an event of interest.
Go stop all threads and look for new ones.
@ -1809,44 +1812,46 @@ thread_db_wait (int pid, struct target_waitstatus *ourstatus)
/* If the process layer does not furnish an lwp,
then perhaps the returned pid IS the lwp... */
if ((lwp = GET_LWP (retpid)) == 0)
#if 0 /* Always true (if it'd compile...) */
if ((lwp = GET_LWP (pid_to_ptid (retpid))) == 0)
#endif
lwp = retpid;
if ((ret = p_td_ta_map_lwp2thr (main_threadagent, lwp, &thandle)) != TD_OK)
return retpid; /* LWP is not mapped onto a user-space thread. */
return pid_to_ptid (retpid); /* LWP is not mapped onto a user-space thread. */
if ((ret = p_td_thr_validate (&thandle)) != TD_OK)
return retpid; /* LWP is not mapped onto a valid thread. */
return pid_to_ptid (retpid); /* LWP is not mapped onto a valid thread. */
if ((ret = p_td_thr_get_info (&thandle, &ti)) != TD_OK)
{
warning ("thread_db: thr_get_info failed ('%s')", thr_err_string (ret));
return retpid;
return pid_to_ptid (retpid);
}
retpid = BUILD_THREAD (ti.ti_tid, main_prochandle.pid);
retptid = BUILD_THREAD (ti.ti_tid, main_prochandle.pid);
/* If this is a new user thread, notify GDB about it. */
if (!in_thread_list (retpid))
if (!in_thread_list (retptid))
{
printf_filtered ("[New %s]\n", target_pid_to_str (retpid));
add_thread (retpid);
printf_filtered ("[New %s]\n", target_pid_to_str (retptid));
add_thread (retptid);
}
#if 0
/* Now detect if this is a thread creation/deletion event: */
check_for_thread_event (ourstatus, retpid);
#endif
return retpid;
return retptid;
}
/*
* kill has to call the underlying kill.
* FIXME: I'm not sure if it's necessary to check inferior_pid any more,
* but we might need to fix inferior_pid up if it's a user thread.
* FIXME: I'm not sure if it's necessary to check inferior_ptid any more,
* but we might need to fix inferior_ptid up if it's a user thread.
*/
static int
kill_thread_callback (td_thrhandle_t *th, void *data)
kill_thread_callback (const td_thrhandle_t *th, void *data)
{
td_thrinfo_t ti;
td_err_e ret;
@ -1874,7 +1879,7 @@ static void thread_db_kill (void)
/* Fixme:
For Linux, threads may need to be waited. */
if (inferior_pid != 0)
if (! ptid_equal (inferior_ptid, null_ptid))
{
/* Go kill the children first. Save the main thread for last. */
p_td_ta_thr_iter (main_threadagent,
@ -1891,7 +1896,7 @@ static void thread_db_kill (void)
detach would not work. */
disable_thread_event_reporting (main_threadagent);
inferior_pid = main_prochandle.pid;
inferior_ptid = pid_to_ptid (main_prochandle.pid);
/*
* Since both procfs_kill and ptrace_kill call target_mourn,
@ -1936,7 +1941,7 @@ static void thread_db_mourn_inferior (void)
*/
static int
detach_thread_callback (td_thrhandle_t *th, void *data)
detach_thread_callback (const td_thrhandle_t *th, void *data)
{
/* Called once per thread. */
td_thrinfo_t ti;
@ -1969,8 +1974,8 @@ detach_thread_callback (td_thrhandle_t *th, void *data)
/* Now cancel any pending SIGTRAPS. FIXME! */
/* Call underlying detach method. FIXME just detach it. */
old_chain = save_inferior_pid ();
inferior_pid = ti.ti_lid;
old_chain = save_inferior_ptid ();
inferior_ptid = pid_to_ptid (ti.ti_lid);
detach (TARGET_SIGNAL_0);
do_cleanups (old_chain);
}
@ -1999,7 +2004,7 @@ thread_db_detach (char *args, int from_tty)
thread_db_unpush_target ();
/* above call nullifies target_beneath, so don't use that! */
inferior_pid = PIDGET (inferior_pid);
inferior_ptid = pid_to_ptid (PIDGET (inferior_ptid));
target_detach (args, from_tty);
}

View File

@ -205,10 +205,11 @@ static CORE_ADDR linuxthreads_breakpoint_addr;
#endif
/* Check to see if the given thread is alive. */
static int
linuxthreads_thread_alive (int pid)
linuxthreads_thread_alive (ptid_t ptid)
{
errno = 0;
return ptrace (PT_READ_U, pid, (PTRACE_ARG3_TYPE)0, 0) >= 0 || errno == 0;
return ptrace (PT_READ_U, PIDGET (ptid), (PTRACE_ARG3_TYPE)0, 0) >= 0
|| errno == 0;
}
/* On detach(), find a SIGTRAP status. If stop is non-zero, find a
@ -308,7 +309,7 @@ linuxthreads_find_trap (int pid, int stop)
for (;;)
{
/* resume the child every time... */
child_resume (pid, 1, TARGET_SIGNAL_0);
child_resume (pid_to_ptid (pid), 1, TARGET_SIGNAL_0);
/* loop as long as errno == EINTR:
waitpid syscall may be aborted due to GDB receiving a signal.
@ -373,24 +374,24 @@ linuxthreads_find_trap (int pid, int stop)
return 1;
}
/* Cleanup stub for save_inferior_pid. */
/* Cleanup stub for save_inferior_ptid. */
static void
restore_inferior_pid (void *arg)
restore_inferior_ptid (void *arg)
{
int *saved_pid_ptr = arg;
inferior_pid = *saved_pid_ptr;
ptid_t *saved_ptid_ptr = arg;
inferior_ptid = *saved_ptid_ptr;
xfree (arg);
}
/* Register a cleanup to restore the value of inferior_pid. */
/* Register a cleanup to restore the value of inferior_ptid. */
static struct cleanup *
save_inferior_pid (void)
save_inferior_ptid (void)
{
int *saved_pid_ptr;
ptid_t *saved_ptid_ptr;
saved_pid_ptr = xmalloc (sizeof (int));
*saved_pid_ptr = inferior_pid;
return make_cleanup (restore_inferior_pid, saved_pid_ptr);
saved_ptid_ptr = xmalloc (sizeof (ptid_t));
*saved_ptid_ptr = inferior_ptid;
return make_cleanup (restore_inferior_ptid, saved_ptid_ptr);
}
static void
@ -633,9 +634,10 @@ remove_breakpoint (int pid)
if (linuxthreads_breakpoint_zombie[j].pid == pid)
break;
if (in_thread_list (pid) && linuxthreads_thread_alive (pid))
if (in_thread_list (pid_to_ptid (pid))
&& linuxthreads_thread_alive (pid_to_ptid (pid)))
{
CORE_ADDR pc = read_pc_pid (pid);
CORE_ADDR pc = read_pc_pid (pid_to_ptid (pid));
if (linuxthreads_breakpoint_addr == pc - DECR_PC_AFTER_BREAK
&& j > linuxthreads_breakpoint_last)
{
@ -651,7 +653,7 @@ remove_breakpoint (int pid)
static void
kill_thread (int pid)
{
if (in_thread_list (pid))
if (in_thread_list (pid_to_ptid (pid)))
{
ptrace (PT_KILL, pid, (PTRACE_ARG3_TYPE) 0, 0);
}
@ -665,17 +667,17 @@ kill_thread (int pid)
static void
resume_thread (int pid)
{
if (pid != inferior_pid
&& in_thread_list (pid)
&& linuxthreads_thread_alive (pid))
if (pid != PIDGET (inferior_ptid)
&& in_thread_list (pid_to_ptid (pid))
&& linuxthreads_thread_alive (pid_to_ptid (pid)))
{
if (pid == linuxthreads_step_pid)
{
child_resume (pid, 1, linuxthreads_step_signo);
child_resume (pid_to_ptid (pid), 1, linuxthreads_step_signo);
}
else
{
child_resume (pid, 0, TARGET_SIGNAL_0);
child_resume (pid_to_ptid (pid), 0, TARGET_SIGNAL_0);
}
}
}
@ -684,14 +686,16 @@ resume_thread (int pid)
static void
detach_thread (int pid)
{
if (in_thread_list (pid) && linuxthreads_thread_alive (pid))
ptid_t ptid = pid_to_ptid (pid);
if (in_thread_list (ptid) && linuxthreads_thread_alive (ptid))
{
/* Remove pending SIGTRAP and SIGSTOP */
linuxthreads_find_trap (pid, 1);
inferior_pid = pid;
inferior_ptid = ptid;
detach (TARGET_SIGNAL_0);
inferior_pid = linuxthreads_manager_pid;
inferior_ptid = pid_to_ptid (linuxthreads_manager_pid);
}
}
@ -707,17 +711,18 @@ attach_thread (int pid)
static void
stop_thread (int pid)
{
if (pid != inferior_pid)
if (pid != PIDGET (inferior_ptid))
{
if (in_thread_list (pid))
if (in_thread_list (pid_to_ptid (pid)))
{
kill (pid, SIGSTOP);
}
else if (ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0) == 0)
{
if (!linuxthreads_attach_pending)
printf_filtered ("[New %s]\n", target_pid_to_str (pid));
add_thread (pid);
printf_filtered ("[New %s]\n",
target_pid_to_str (pid_to_ptid (pid)));
add_thread (pid_to_ptid (pid));
if (linuxthreads_sig_debug.signal)
{
/* After a new thread in glibc 2.1 signals gdb its existence,
@ -738,7 +743,7 @@ wait_thread (int pid)
int status;
int rpid;
if (pid != inferior_pid && in_thread_list (pid))
if (pid != PIDGET (inferior_ptid) && in_thread_list (pid_to_ptid (pid)))
{
/* loop as long as errno == EINTR:
waitpid syscall may be aborted if GDB receives a signal.
@ -778,7 +783,7 @@ wait_thread (int pid)
{
break;
}
if (errno != EINTR && linuxthreads_thread_alive (pid))
if (errno != EINTR && linuxthreads_thread_alive (pid_to_ptid (pid)))
perror_with_name ("wait_thread/waitpid");
/* the thread is dead. */
@ -805,20 +810,20 @@ update_stop_threads (int test_pid)
{
if (linuxthreads_manager)
{
if (test_pid > 0 && test_pid != inferior_pid)
if (test_pid > 0 && test_pid != PIDGET (inferior_ptid))
{
old_chain = save_inferior_pid ();
inferior_pid = test_pid;
old_chain = save_inferior_ptid ();
inferior_ptid = pid_to_ptid (test_pid);
}
read_memory (linuxthreads_manager,
(char *)&linuxthreads_manager_pid, sizeof (pid_t));
}
if (linuxthreads_initial)
{
if (test_pid > 0 && test_pid != inferior_pid)
if (test_pid > 0 && test_pid != PIDGET (inferior_ptid))
{
old_chain = save_inferior_pid ();
inferior_pid = test_pid;
old_chain = save_inferior_ptid ();
inferior_ptid = pid_to_ptid (test_pid);
}
read_memory(linuxthreads_initial,
(char *)&linuxthreads_initial_pid, sizeof (pid_t));
@ -828,13 +833,14 @@ update_stop_threads (int test_pid)
if (linuxthreads_manager_pid != 0)
{
if (old_chain == NULL && test_pid > 0 &&
test_pid != inferior_pid && linuxthreads_thread_alive (test_pid))
test_pid != PIDGET (inferior_ptid)
&& linuxthreads_thread_alive (pid_to_ptid (test_pid)))
{
old_chain = save_inferior_pid ();
inferior_pid = test_pid;
old_chain = save_inferior_ptid ();
inferior_ptid = pid_to_ptid (test_pid);
}
if (linuxthreads_thread_alive (inferior_pid))
if (linuxthreads_thread_alive (inferior_ptid))
{
if (test_pid > 0)
{
@ -844,14 +850,14 @@ update_stop_threads (int test_pid)
stop_thread (linuxthreads_manager_pid);
wait_thread (linuxthreads_manager_pid);
}
if (!in_thread_list (test_pid))
if (!in_thread_list (pid_to_ptid (test_pid)))
{
if (!linuxthreads_attach_pending)
printf_filtered ("[New %s]\n",
target_pid_to_str (test_pid));
add_thread (test_pid);
target_pid_to_str (pid_to_ptid (test_pid)));
add_thread (pid_to_ptid (test_pid));
if (linuxthreads_sig_debug.signal
&& inferior_pid == test_pid)
&& PIDGET (inferior_ptid) == test_pid)
{
/* After a new thread in glibc 2.1 signals gdb its
existence, it suspends itself and wait for
@ -1033,7 +1039,7 @@ any thread other than the main thread.");
linuxthreads_breakpoint_zombie = (struct linuxthreads_breakpoint *)
xmalloc (sizeof (struct linuxthreads_breakpoint) * (linuxthreads_max + 1));
if (inferior_pid &&
if (PIDGET (inferior_ptid) != 0 &&
!linuxthreads_attach_pending &&
!using_thread_db) /* suppressed by thread_db module */
{
@ -1041,7 +1047,7 @@ any thread other than the main thread.");
target_write_memory (linuxthreads_debug, (char *)&on, sizeof (on));
linuxthreads_attach_pending = 1;
update_stop_threads (inferior_pid);
update_stop_threads (PIDGET (inferior_ptid));
linuxthreads_attach_pending = 0;
}
@ -1062,13 +1068,14 @@ linuxthreads_prepare_to_proceed (int step)
if (!linuxthreads_max
|| !linuxthreads_manager_pid
|| !linuxthreads_breakpoint_pid
|| !breakpoint_here_p (read_pc_pid (linuxthreads_breakpoint_pid)))
|| !breakpoint_here_p (
read_pc_pid (pid_to_ptid (linuxthreads_breakpoint_pid))))
return 0;
if (step)
{
/* Mark the current inferior as single stepping process. */
linuxthreads_step_pid = inferior_pid;
linuxthreads_step_pid = PIDGET (inferior_ptid);
}
linuxthreads_inferior_pid = linuxthreads_breakpoint_pid;
@ -1078,9 +1085,10 @@ linuxthreads_prepare_to_proceed (int step)
/* Convert a pid to printable form. */
char *
linuxthreads_pid_to_str (int pid)
linuxthreads_pid_to_str (ptid_t ptid)
{
static char buf[100];
int pid = PIDGET (ptid);
sprintf (buf, "%s %d%s", linuxthreads_max ? "Thread" : "Pid", pid,
(pid == linuxthreads_manager_pid) ? " (manager thread)"
@ -1139,26 +1147,28 @@ linuxthreads_detach (char *args, int from_tty)
continue;
pid = linuxthreads_breakpoint_zombie[i].pid;
if (!linuxthreads_thread_alive (pid))
if (!linuxthreads_thread_alive (pid_to_ptid (pid)))
continue;
if (linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (pid))
if (linuxthreads_breakpoint_zombie[i].pc
!= read_pc_pid (pid_to_ptid (pid)))
continue;
/* Continue in STEP mode until the thread pc has moved or
until SIGTRAP is found on the same PC. */
if (linuxthreads_find_trap (pid, 0)
&& linuxthreads_breakpoint_zombie[i].pc == read_pc_pid (pid))
&& linuxthreads_breakpoint_zombie[i].pc
== read_pc_pid (pid_to_ptid (pid)))
write_pc_pid (linuxthreads_breakpoint_zombie[i].pc
- DECR_PC_AFTER_BREAK, pid);
- DECR_PC_AFTER_BREAK, pid_to_ptid (pid));
}
/* Detach thread after thread. */
inferior_pid = linuxthreads_manager_pid;
inferior_ptid = pid_to_ptid (linuxthreads_manager_pid);
iterate_active_threads (detach_thread, 1);
/* Remove pending SIGTRAP and SIGSTOP */
linuxthreads_find_trap (inferior_pid, 1);
linuxthreads_find_trap (PIDGET (inferior_ptid), 1);
linuxthreads_wait_last = -1;
WSETSTOP (linuxthreads_exit_status, 0);
@ -1184,11 +1194,11 @@ linuxthreads_detach (char *args, int from_tty)
signal activated. */
static void
linuxthreads_resume (int pid, int step, enum target_signal signo)
linuxthreads_resume (ptid_t ptid, int step, enum target_signal signo)
{
if (!linuxthreads_max || stop_soon_quietly || linuxthreads_manager_pid == 0)
{
child_ops.to_resume (pid, step, signo);
child_ops.to_resume (ptid, step, signo);
}
else
{
@ -1205,28 +1215,28 @@ linuxthreads_resume (int pid, int step, enum target_signal signo)
struct cleanup *old_chain = NULL;
int i;
if (pid < 0)
if (PIDGET (ptid) < 0)
{
linuxthreads_step_pid = step ? inferior_pid : 0;
linuxthreads_step_pid = step ? PIDGET (inferior_ptid) : 0;
linuxthreads_step_signo = signo;
rpid = inferior_pid;
rpid = PIDGET (inferior_ptid);
}
else
rpid = pid;
rpid = PIDGET (ptid);
if (pid < 0 || !step)
if (PIDGET (ptid) < 0 || !step)
{
linuxthreads_breakpoints_inserted = 1;
/* Walk through linuxthreads array in order to resume threads */
if (pid >= 0 && inferior_pid != pid)
if (PIDGET (ptid) >= 0 && !ptid_equal (inferior_ptid, ptid))
{
old_chain = save_inferior_pid ();
inferior_pid = pid;
old_chain = save_inferior_ptid ();
inferior_ptid = ptid;
}
iterate_active_threads (resume_thread, 0);
if (linuxthreads_manager_pid != inferior_pid
if (linuxthreads_manager_pid != PIDGET (inferior_ptid)
&& !linuxthreads_pending_status (linuxthreads_manager_pid))
resume_thread (linuxthreads_manager_pid);
}
@ -1237,7 +1247,8 @@ linuxthreads_resume (int pid, int step, enum target_signal signo)
for (i = 0; i <= linuxthreads_breakpoint_last; i++)
if (linuxthreads_breakpoint_zombie[i].pid == rpid)
{
if (linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (rpid))
if (linuxthreads_breakpoint_zombie[i].pc
!= read_pc_pid (pid_to_ptid (rpid)))
{
/* The current pc is out of zombie breakpoint. */
REMOVE_BREAKPOINT_ZOMBIE(i);
@ -1253,7 +1264,7 @@ linuxthreads_resume (int pid, int step, enum target_signal signo)
/* [unles it has a wait event pending] */
if (!linuxthreads_pending_status (rpid))
{
child_ops.to_resume (rpid, step, signo);
child_ops.to_resume (pid_to_ptid (rpid), step, signo);
}
}
}
@ -1313,14 +1324,15 @@ linux_child_wait (int pid, int *rpid, int *status)
/* Wait for any threads to stop. We may have to convert PID from a thread id
to a LWP id, and vice versa on the way out. */
static int
linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
static ptid_t
linuxthreads_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
int status;
int rpid;
int i;
int last;
int *wstatus;
int pid = PIDGET (ptid);
if (linuxthreads_max && !linuxthreads_breakpoints_inserted)
wstatus = alloca (LINUXTHREAD_NSIG * sizeof (int));
@ -1340,7 +1352,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
if (linuxthreads_inferior_pid)
pid = linuxthreads_inferior_pid;
else if (pid < 0)
pid = inferior_pid;
pid = PIDGET (inferior_ptid);
last = rpid = 0;
}
else if (pid < 0 && linuxthreads_wait_last >= 0)
@ -1383,7 +1395,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
if (WIFEXITED(linuxthreads_exit_status))
{
store_waitstatus (ourstatus, linuxthreads_exit_status);
return inferior_pid;
return inferior_ptid;
}
else
{
@ -1393,7 +1405,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
/* Claim it exited with unknown signal. */
ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
return -1;
return pid_to_ptid (-1);
}
}
@ -1420,7 +1432,8 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
linuxthreads_breakpoint_zombie[i].pid = rpid;
linuxthreads_breakpoint_last++;
}
linuxthreads_breakpoint_zombie[i].pc = read_pc_pid (rpid);
linuxthreads_breakpoint_zombie[i].pc
= read_pc_pid (pid_to_ptid (rpid));
linuxthreads_breakpoint_zombie[i].step = 1;
}
else
@ -1435,7 +1448,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
wstatus[last++] = status;
}
}
child_resume (rpid, 1, TARGET_SIGNAL_0);
child_resume (pid_to_ptid (rpid), 1, TARGET_SIGNAL_0);
continue;
}
if (linuxthreads_inferior_pid)
@ -1453,11 +1466,12 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
{
if (linuxthreads_step_pid == rpid)
{
child_resume (rpid, 1, linuxthreads_step_signo);
child_resume (pid_to_ptid (rpid), 1,
linuxthreads_step_signo);
}
else
{
child_resume (rpid, 0, TARGET_SIGNAL_0);
child_resume (pid_to_ptid (rpid), 0, TARGET_SIGNAL_0);
}
}
continue;
@ -1490,7 +1504,8 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
{
/* There is a potential zombie breakpoint */
if (WIFEXITED(status)
|| linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (rpid))
|| linuxthreads_breakpoint_zombie[i].pc
!= read_pc_pid (pid_to_ptid (rpid)))
{
/* The current pc is out of zombie breakpoint. */
REMOVE_BREAKPOINT_ZOMBIE(i);
@ -1500,14 +1515,14 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
{
/* This is a real one ==> decrement PC and restart. */
write_pc_pid (linuxthreads_breakpoint_zombie[i].pc
- DECR_PC_AFTER_BREAK, rpid);
- DECR_PC_AFTER_BREAK, pid_to_ptid (rpid));
if (linuxthreads_step_pid == rpid)
{
child_resume (rpid, 1, linuxthreads_step_signo);
child_resume (pid_to_ptid (rpid), 1, linuxthreads_step_signo);
}
else
{
child_resume (rpid, 0, TARGET_SIGNAL_0);
child_resume (pid_to_ptid (rpid), 0, TARGET_SIGNAL_0);
}
continue;
}
@ -1518,7 +1533,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
update_stop_threads (rpid);
}
else if (rpid != inferior_pid)
else if (rpid != PIDGET (inferior_ptid))
continue;
store_waitstatus (ourstatus, status);
@ -1542,7 +1557,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus)
else if (linuxthreads_breakpoint_pid)
linuxthreads_breakpoint_pid = 0;
return rpid;
return pid_to_ptid (rpid);
}
}
@ -1610,17 +1625,17 @@ linuxthreads_kill (void)
int rpid;
int status;
if (inferior_pid == 0)
if (PIDGET (inferior_ptid) == 0)
return;
if (linuxthreads_max && linuxthreads_manager_pid != 0)
{
/* Remove all threads status. */
inferior_pid = linuxthreads_manager_pid;
inferior_ptid = pid_to_ptid (linuxthreads_manager_pid);
iterate_active_threads (kill_thread, 1);
}
kill_thread (inferior_pid);
kill_thread (PIDGET (inferior_ptid));
#if 0
/* doing_quit_force solves a real problem, but I think a properly
@ -1639,9 +1654,9 @@ linuxthreads_kill (void)
kill_thread (rpid);
}
else
while ((rpid = waitpid (inferior_pid, &status, 0)) > 0)
while ((rpid = waitpid (PIDGET (inferior_ptid), &status, 0)) > 0)
if (!WIFEXITED(status))
ptrace (PT_KILL, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0);
ptrace (PT_KILL, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) 0, 0);
}
#endif

View File

@ -287,8 +287,8 @@ fetch_inferior_registers (int regno)
int i;
errno = 0;
retval = ptrace (PTRACE_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) & ec,
0);
retval = ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & ec, 0);
if (errno)
perror_with_name ("ptrace(PTRACE_GETREGS)");
@ -340,8 +340,8 @@ fetch_inferior_registers (int regno)
int i;
errno = 0;
retval = ptrace (PTRACE_GETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) & fc,
0);
retval = ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & fc, 0);
if (errno)
perror_with_name ("ptrace(PTRACE_GETFPREGS)");
@ -396,8 +396,8 @@ store_inferior_registers (int regno)
8 * REGISTER_RAW_SIZE (O0_REGNUM));
errno = 0;
retval = ptrace (PTRACE_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) & ec,
0);
retval = ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & ec, 0);
if (errno)
perror_with_name ("ptrace(PTRACE_SETREGS)");
}
@ -444,8 +444,8 @@ store_inferior_registers (int regno)
/* We read fcontext first so that we can get good values for fq_t... */
errno = 0;
retval = ptrace (PTRACE_GETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) & fc,
0);
retval = ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & fc, 0);
if (errno)
perror_with_name ("ptrace(PTRACE_GETFPREGS)");
@ -455,8 +455,8 @@ store_inferior_registers (int regno)
fc.fsr = read_register (FPS_REGNUM);
errno = 0;
retval = ptrace (PTRACE_SETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) & fc,
0);
retval = ptrace (PTRACE_SETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & fc, 0);
if (errno)
perror_with_name ("ptrace(PTRACE_SETFPREGS)");
}
@ -508,7 +508,7 @@ fetch_inferior_registers (int regno)
else
reglo = reghi = regno;
ecp = registers_addr (inferior_pid);
ecp = registers_addr (PIDGET (inferior_ptid));
for (regno = reglo; regno <= reghi; regno++)
{
@ -524,7 +524,7 @@ fetch_inferior_registers (int regno)
unsigned int reg;
errno = 0;
reg = ptrace (ptrace_fun, inferior_pid,
reg = ptrace (ptrace_fun, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) (ecp + regmap[regno] + i), 0);
if (errno)
perror_with_name ("ptrace(PTRACE_PEEKUSP)");
@ -559,7 +559,7 @@ store_inferior_registers (int regno)
else
reglo = reghi = regno;
ecp = registers_addr (inferior_pid);
ecp = registers_addr (PIDGET (inferior_ptid));
for (regno = reglo; regno <= reghi; regno++)
{
@ -579,7 +579,7 @@ store_inferior_registers (int regno)
reg = *(unsigned int *) &registers[REGISTER_BYTE (regno) + i];
errno = 0;
ptrace (ptrace_fun, inferior_pid,
ptrace (ptrace_fun, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) (ecp + regmap[regno] + i), reg);
if (errno)
perror_with_name ("ptrace(PTRACE_POKEUSP)");
@ -591,12 +591,13 @@ store_inferior_registers (int regno)
/* Wait for child to do something. Return pid of child, or -1 in case
of error; store status through argument pointer OURSTATUS. */
int
child_wait (int pid, struct target_waitstatus *ourstatus)
ptid_t
child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
int save_errno;
int thread;
union wait status;
int pid;
while (1)
{
@ -622,7 +623,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
return -1;
}
if (pid != PIDGET (inferior_pid)) /* Some other process?!? */
if (pid != PIDGET (inferior_ptid)) /* Some other process?!? */
continue;
thread = status.w_tid; /* Get thread id from status */
@ -630,26 +631,27 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
/* Initial thread value can only be acquired via wait, so we have to
resort to this hack. */
if (TIDGET (inferior_pid) == 0 && thread != 0)
if (TIDGET (inferior_ptid) == 0 && thread != 0)
{
inferior_pid = BUILDPID (inferior_pid, thread);
add_thread (inferior_pid);
inferior_ptid = MERGEPID (PIDGET (inferior_ptid), thread);
add_thread (inferior_ptid);
}
pid = BUILDPID (pid, thread);
ptid = BUILDPID (pid, thread);
/* We've become a single threaded process again. */
if (thread == 0)
inferior_pid = pid;
inferior_ptid = ptid;
/* Check for thread creation. */
if (WIFSTOPPED (status)
&& WSTOPSIG (status) == SIGTRAP
&& !in_thread_list (pid))
&& !in_thread_list (ptid))
{
int realsig;
realsig = ptrace (PTRACE_GETTRACESIG, pid, (PTRACE_ARG3_TYPE) 0, 0);
realsig = ptrace (PTRACE_GETTRACESIG, PIDGET (ptid),
(PTRACE_ARG3_TYPE) 0, 0);
if (realsig == SIGNEWTHREAD)
{
@ -657,7 +659,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
realsig -- the code in wait_for_inferior expects SIGTRAP. */
ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
ourstatus->value.sig = TARGET_SIGNAL_0;
return pid;
return ptid;
}
else
error ("Signal for unknown thread was not SIGNEWTHREAD");
@ -666,15 +668,16 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
/* Check for thread termination. */
else if (WIFSTOPPED (status)
&& WSTOPSIG (status) == SIGTRAP
&& in_thread_list (pid))
&& in_thread_list (ptid))
{
int realsig;
realsig = ptrace (PTRACE_GETTRACESIG, pid, (PTRACE_ARG3_TYPE) 0, 0);
realsig = ptrace (PTRACE_GETTRACESIG, PIDGET (ptid),
(PTRACE_ARG3_TYPE) 0, 0);
if (realsig == SIGTHREADEXIT)
{
ptrace (PTRACE_CONT, PIDGET (pid), (PTRACE_ARG3_TYPE) 0, 0);
ptrace (PTRACE_CONT, PIDGET (ptid), (PTRACE_ARG3_TYPE) 0, 0);
continue;
}
}
@ -705,14 +708,16 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
store_waitstatus (ourstatus, status.w_status);
#endif
return pid;
return ptid;
}
}
/* Return nonzero if the given thread is still alive. */
int
child_thread_alive (int pid)
child_thread_alive (ptid_t ptid)
{
int pid = PIDGET (ptid);
/* Arggh. Apparently pthread_kill only works for threads within
the process that calls pthread_kill.
@ -730,9 +735,10 @@ child_thread_alive (int pid)
If SIGNAL is nonzero, give it that signal. */
void
child_resume (int pid, int step, enum target_signal signal)
child_resume (ptid_t ptid, int step, enum target_signal signal)
{
int func;
int pid = PIDGET (ptid);
errno = 0;
@ -740,7 +746,7 @@ child_resume (int pid, int step, enum target_signal signal)
we only want to step/continue a single thread. */
if (pid == -1)
{
pid = inferior_pid;
pid = PIDGET (inferior_ptid);
func = step ? PTRACE_SINGLESTEP : PTRACE_CONT;
}
else
@ -766,11 +772,11 @@ child_resume (int pid, int step, enum target_signal signal)
buffer. */
char *
child_pid_to_str (int pid)
child_pid_to_str (ptid_t ptid)
{
static char buf[40];
sprintf (buf, "process %d thread %d", PIDGET (pid), TIDGET (pid));
sprintf (buf, "process %d thread %d", PIDGET (ptid), TIDGET (ptid));
return buf;
}

View File

@ -1232,10 +1232,10 @@ int mach_really_waiting;
There is no other way to exit this loop.
Returns the inferior_pid for rest of gdb.
Returns the inferior_ptid for rest of gdb.
Side effects: Set *OURSTATUS. */
int
mach_really_wait (int pid, struct target_waitstatus *ourstatus)
ptid_t
mach_really_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
kern_return_t ret;
int w;
@ -1311,7 +1311,7 @@ mach_really_wait (int pid, struct target_waitstatus *ourstatus)
}
}
store_waitstatus (ourstatus, w);
return inferior_pid;
return inferior_ptid;
}
}
@ -1346,7 +1346,7 @@ mach_really_wait (int pid, struct target_waitstatus *ourstatus)
mach3_exception_actions (&w, FALSE, "Task");
store_waitstatus (ourstatus, w);
return inferior_pid;
return inferior_ptid;
}
}
}
@ -3815,14 +3815,14 @@ kill_inferior_fast (void)
{
WAITTYPE w;
if (inferior_pid == 0 || inferior_pid == 1)
if (PIDGET (inferior_ptid) == 0 || PIDGET (inferior_ptid) == 1)
return;
/* kill() it, since the Unix server does not otherwise notice when
* killed with task_terminate().
*/
if (inferior_pid > 0)
kill (inferior_pid, SIGKILL);
if (PIDGET (inferior_ptid) > 0)
kill (PIDGET (inferior_ptid), SIGKILL);
/* It's propably terminate already */
(void) task_terminate (inferior_task);
@ -3884,7 +3884,7 @@ ptrace (int a, int b, int c, int d)
If SIGNAL is nonzero, give it that signal. */
void
m3_resume (int pid, int step, enum target_signal signal)
m3_resume (ptid_t ptid, int step, enum target_signal signal)
{
kern_return_t ret;
@ -3913,8 +3913,8 @@ m3_resume (int pid, int step, enum target_signal signal)
vm_read_cache_valid = FALSE;
if (signal && inferior_pid > 0) /* Do not signal, if attached by MID */
kill (inferior_pid, target_signal_to_host (signal));
if (signal && PIDGET (inferior_ptid) > 0) /* Do not signal, if attached by MID */
kill (PIDGET (inferior_ptid), target_signal_to_host (signal));
if (step)
{
@ -4014,10 +4014,10 @@ m3_do_attach (int pid)
{
mid_attach (-(pid));
/* inferior_pid will be NEGATIVE! */
inferior_pid = pid;
/* inferior_ptid will be NEGATIVE! */
inferior_ptid = pid_to_ptid (pid);
return inferior_pid;
return PIDGET (inferior_ptid);
}
inferior_task = task_by_pid (pid);
@ -4026,9 +4026,9 @@ m3_do_attach (int pid)
task_attach (inferior_task);
inferior_pid = pid;
inferior_ptid = pid_to_ptid (pid);
return inferior_pid;
return PIDGET (inferior_ptid);
}
/* Attach to process PID, then initialize for debugging it
@ -4053,15 +4053,17 @@ m3_attach (char *args, int from_tty)
exec_file = (char *) get_exec_file (0);
if (exec_file)
printf_unfiltered ("Attaching to program `%s', %s\n", exec_file, target_pid_to_str (pid));
printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
target_pid_to_str (pid_to_ptid (pid)));
else
printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
printf_unfiltered ("Attaching to %s\n",
target_pid_to_str (pid_to_ptid (pid)));
gdb_flush (gdb_stdout);
}
m3_do_attach (pid);
inferior_pid = pid;
m3_do_attach (pid_to_ptid (pid));
inferior_ptid = pid_to_ptid (pid);
push_target (&m3_ops);
}
@ -4149,8 +4151,8 @@ m3_do_detach (int signal)
if (remove_breakpoints ())
warning ("Could not remove breakpoints when detaching");
if (signal && inferior_pid > 0)
kill (inferior_pid, signal);
if (signal && PIDGET (inferior_ptid) > 0)
kill (PIDGET (inferior_ptid), signal);
/* the task might be dead by now */
(void) task_resume (inferior_task);
@ -4179,14 +4181,14 @@ m3_detach (char *args, int from_tty)
if (exec_file == 0)
exec_file = "";
printf_unfiltered ("Detaching from program: %s %s\n",
exec_file, target_pid_to_str (inferior_pid));
exec_file, target_pid_to_str (inferior_ptid));
gdb_flush (gdb_stdout);
}
if (args)
siggnal = atoi (args);
m3_do_detach (siggnal);
inferior_pid = 0;
inferior_ptid = null_ptid;
unpush_target (&m3_ops); /* Pop out of handling an inferior */
}
#endif /* ATTACH_DETACH */
@ -4212,7 +4214,7 @@ m3_files_info (struct target_ops *ignore)
{
/* FIXME: should print MID and all that crap. */
printf_unfiltered ("\tUsing the running image of %s %s.\n",
attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid));
attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid));
}
static void
@ -4458,7 +4460,7 @@ init_m3_ops (void)
m3_ops.to_attach = m3_attach;
m3_ops.to_detach = m3_detach;
m3_ops.to_resume = m3_resume;
m3_ops.to_wait = mach_really__wait;
m3_ops.to_wait = mach_really_wait;
m3_ops.to_fetch_registers = fetch_inferior_registers;
m3_ops.to_store_registers = store_inferior_registers;
m3_ops.to_prepare_to_store = m3_prepare_to_store;

View File

@ -110,7 +110,6 @@ m32r_load_1 (void *dummy)
static void
m32r_load (char *filename, int from_tty)
{
extern int inferior_pid;
bfd *abfd;
asection *s;
unsigned int i, data_count = 0;
@ -166,7 +165,7 @@ m32r_load (char *filename, int from_tty)
if (exec_bfd)
write_pc (bfd_get_start_address (exec_bfd));
inferior_pid = 0; /* No process now */
inferior_ptid = null_ptid; /* No process now */
/* This is necessary because many things were based on the PC at the
time that we attached to the monitor, which is no longer valid
@ -458,7 +457,6 @@ m32r_upload_command (char *args, int from_tty)
bfd *abfd;
asection *s;
time_t start_time, end_time; /* for timing of download */
extern int inferior_pid;
int resp_len, data_count = 0;
char buf[1024];
struct hostent *hostent;
@ -565,7 +563,7 @@ m32r_upload_command (char *args, int from_tty)
report_transfer_performance (data_count, start_time, end_time);
printf_filtered ("Start address 0x%lx\n", bfd_get_start_address (abfd));
}
inferior_pid = 0; /* No process now */
inferior_ptid = null_ptid; /* No process now */
/* This is necessary because many things were based on the PC at the
time that we attached to the monitor, which is no longer valid

View File

@ -34,12 +34,12 @@ fetch_inferior_registers (int regno)
struct reg inferior_registers;
struct fpreg inferior_fp_registers;
ptrace (PT_GETREGS, inferior_pid,
ptrace (PT_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers, 0);
memcpy (&registers[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 (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
sizeof (inferior_fp_registers));
@ -55,12 +55,12 @@ store_inferior_registers (int regno)
memcpy (&inferior_registers, &registers[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, &registers[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);
}

View File

@ -76,7 +76,7 @@ fetch_inferior_registers (int regno)
offset = (char *) &u.pt_r0 - (char *) &u;
regaddr = offset; /* byte offset to r0; */
/* offset = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
/* offset = ptrace (3, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
for (regno = 0; regno < NUM_REGS; regno++)
{
/*regaddr = register_addr (regno, offset); */
@ -84,20 +84,20 @@ fetch_inferior_registers (int regno)
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
{
*(int *) &buf[i] = ptrace (3, inferior_pid,
*(int *) &buf[i] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, 0);
regaddr += sizeof (int);
}
supply_register (regno, buf);
}
/* now load up registers 36 - 38; special pc registers */
*(int *) &buf[0] = ptrace (3, inferior_pid,
*(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SXIP_OFFSET, 0);
supply_register (SXIP_REGNUM, buf);
*(int *) &buf[0] = ptrace (3, inferior_pid,
*(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SNIP_OFFSET, 0);
supply_register (SNIP_REGNUM, buf);
*(int *) &buf[0] = ptrace (3, inferior_pid,
*(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SFIP_OFFSET, 0);
supply_register (SFIP_REGNUM, buf);
}
@ -128,7 +128,7 @@ store_inferior_registers (int regno)
{
regaddr = offset + regno * sizeof (int);
errno = 0;
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, read_register (regno));
if (errno != 0)
{
@ -137,13 +137,13 @@ store_inferior_registers (int regno)
}
}
else if (regno == SXIP_REGNUM)
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SXIP_OFFSET, read_register (regno));
else if (regno == SNIP_REGNUM)
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SNIP_OFFSET, read_register (regno));
else if (regno == SFIP_REGNUM)
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SFIP_OFFSET, read_register (regno));
else
printf_unfiltered ("Bad register number for store_inferior routine\n");
@ -155,7 +155,7 @@ store_inferior_registers (int regno)
/* regaddr = register_addr (regno, offset); */
errno = 0;
regaddr = offset + regno * sizeof (int);
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, read_register (regno));
if (errno != 0)
{
@ -163,11 +163,11 @@ store_inferior_registers (int regno)
perror_with_name (buf);
}
}
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SXIP_OFFSET, read_register (SXIP_REGNUM));
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SNIP_OFFSET, read_register (SNIP_REGNUM));
ptrace (6, inferior_pid,
ptrace (6, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) SFIP_OFFSET, read_register (SFIP_REGNUM));
}
}

View File

@ -78,8 +78,8 @@ child_store_inferior_registers (int r)
}
}
static int
child_wait (int pid, struct target_waitstatus *ourstatus)
static ptid_t
child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
}
@ -116,15 +116,16 @@ child_attach (char *args, int from_tty)
if (exec_file)
printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
target_pid_to_str (pid));
target_pid_to_str (pid_to_ptid (pid)));
else
printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
printf_unfiltered ("Attaching to %s\n",
target_pid_to_str (pid_to_ptid (pid)));
gdb_flush (gdb_stdout);
}
/* Do we need to do anything special? */
attach_flag = 1;
inferior_pid = pid;
inferior_ptid = pid_to_ptid (pid);
push_target (&child_ops);
}
}
@ -140,10 +141,10 @@ child_detach (char *args, int from_tty)
if (exec_file == 0)
exec_file = "";
printf_unfiltered ("Detaching from program: %s %s\n", exec_file,
target_pid_to_str (inferior_pid));
target_pid_to_str (inferior_ptid));
gdb_flush (gdb_stdout);
}
inferior_pid = 0;
inferior_ptid = null_ptid;
unpush_target (&child_ops);
}
@ -153,7 +154,7 @@ static void
child_files_info (struct target_ops *ignore)
{
printf_unfiltered ("\tUsing the running image of %s %s.\n",
attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid));
attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid));
}
/* ARGSUSED */
@ -163,7 +164,7 @@ child_open (char *arg, int from_tty)
error ("Use the \"run\" command to start a Mac application.");
}
/* Start an inferior Mac program and sets inferior_pid to its pid.
/* Start an inferior Mac program and sets inferior_ptid to its pid.
EXEC_FILE is the file to run.
ALLARGS is a string containing the arguments to the program.
ENV is the environment vector to pass. Errors reported with error(). */
@ -202,7 +203,7 @@ child_create_inferior (char *exec_file, char *allargs, char **env)
error ("Error launching %s, code %d\n", exec_file, launch_err);
}
inferior_pid = launchparms.launchProcessSN.lowLongOfPSN;
inferior_ptid = pid_to_ptid (launchparms.launchProcessSN.lowLongOfPSN);
/* FIXME be sure that high long of PSN is 0 */
push_target (&child_ops);
@ -251,7 +252,7 @@ child_kill_inferior (void)
}
void
child_resume (int pid, int step, enum target_signal signal)
child_resume (ptid_t ptid, int step, enum target_signal signal)
{
}

View File

@ -83,7 +83,7 @@ fetch_inferior_registers (int regno)
regaddr = REGISTER_PTRACE_ADDR (regno);
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
{
*(int *) &buf[i] = ptrace (PT_READ_U, inferior_pid,
*(int *) &buf[i] = ptrace (PT_READ_U, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) regaddr, 0);
regaddr += sizeof (int);
}
@ -114,7 +114,7 @@ store_inferior_registers (int regno)
return;
regaddr = REGISTER_PTRACE_ADDR (regno);
errno = 0;
ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
ptrace (PT_WRITE_U, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr,
read_register (regno));
if (errno != 0)
{

View File

@ -546,9 +546,9 @@ pc_is_mips16 (bfd_vma memaddr)
all registers should be sign extended for simplicity? */
static CORE_ADDR
mips_read_pc (int pid)
mips_read_pc (ptid_t ptid)
{
return read_signed_register_pid (PC_REGNUM, pid);
return read_signed_register_pid (PC_REGNUM, ptid);
}
/* This returns the PC of the first inst after the prologue. If we can't

View File

@ -42,14 +42,12 @@ static void mon960_open (char *args, int from_tty);
static void
mon960_load_gen (char *filename, int from_tty)
{
extern int inferior_pid;
generic_load (filename, from_tty);
/* Finally, make the PC point at the start address */
if (exec_bfd)
write_pc (bfd_get_start_address (exec_bfd));
inferior_pid = 0; /* No process now */
inferior_ptid = null_ptid; /* No process now */
}
#else

View File

@ -67,13 +67,13 @@ static void monitor_store_register (int regno);
static void monitor_printable_string (char *newstr, char *oldstr, int len);
static void monitor_error (char *function, char *message, CORE_ADDR memaddr, int len, char *string, int final_char);
static void monitor_detach (char *args, int from_tty);
static void monitor_resume (int pid, int step, enum target_signal sig);
static void monitor_resume (ptid_t ptid, int step, enum target_signal sig);
static void monitor_interrupt (int signo);
static void monitor_interrupt_twice (int signo);
static void monitor_interrupt_query (void);
static void monitor_wait_cleanup (void *old_timeout);
static int monitor_wait (int pid, struct target_waitstatus *status);
static ptid_t monitor_wait (ptid_t ptid, struct target_waitstatus *status);
static void monitor_fetch_registers (int regno);
static void monitor_store_registers (int regno);
static void monitor_prepare_to_store (void);
@ -833,7 +833,7 @@ monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
push_target (targ_ops);
inferior_pid = 42000; /* Make run command think we are busy... */
inferior_ptid = pid_to_ptid (42000); /* Make run command think we are busy... */
/* Give monitor_wait something to read */
@ -922,7 +922,7 @@ monitor_supply_register (int regno, char *valstr)
/* Tell the remote machine to resume. */
static void
monitor_resume (int pid, int step, enum target_signal sig)
monitor_resume (ptid_t ptid, int step, enum target_signal sig)
{
/* Some monitors require a different command when starting a program */
monitor_debug ("MON resume\n");
@ -1072,8 +1072,8 @@ monitor_wait_filter (char *buf,
/* Wait until the remote machine stops, then return, storing status in
status just as `wait' would. */
static int
monitor_wait (int pid, struct target_waitstatus *status)
static ptid_t
monitor_wait (ptid_t ptid, struct target_waitstatus *status)
{
int old_timeout = timeout;
char buf[TARGET_BUF_SIZE];
@ -1149,7 +1149,7 @@ monitor_wait (int pid, struct target_waitstatus *status)
in_monitor_wait = 0;
return inferior_pid;
return inferior_ptid;
}
/* Fetch register REGNO, or all registers if REGNO is -1. Returns
@ -2180,7 +2180,7 @@ monitor_load (char *file, int from_tty)
if (exec_bfd)
write_pc (bfd_get_start_address (exec_bfd));
inferior_pid = 0; /* No process now */
inferior_ptid = null_ptid ; /* No process now */
/* This is necessary because many things were based on the PC at the time that
we attached to the monitor, which is no longer valid now that we have loaded

View File

@ -43,9 +43,9 @@ fetch_inferior_registers (int regno)
struct reg inferior_registers;
struct fpreg inferior_fpregisters;
ptrace (PT_GETREGS, inferior_pid,
ptrace (PT_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers, 0);
ptrace (PT_GETFPREGS, inferior_pid,
ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_fpregisters, 0);
RF (R0_REGNUM + 0, inferior_registers.r_r0);
@ -104,9 +104,9 @@ store_inferior_registers (int regno)
RS (LP0_REGNUM + 5, inferior_fpregisters.r_freg[5]);
RS (LP0_REGNUM + 7, inferior_fpregisters.r_freg[7]);
ptrace (PT_SETREGS, inferior_pid,
ptrace (PT_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers, 0);
ptrace (PT_SETFPREGS, inferior_pid,
ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_fpregisters, 0);
}

View File

@ -151,7 +151,7 @@ ocd_error (char *s, int error_code)
/* Return nonzero if the thread TH is still alive on the remote system. */
int
ocd_thread_alive (int th)
ocd_thread_alive (ptid_t th)
{
return 1;
}
@ -344,7 +344,7 @@ device the OCD device is attached to (e.g. /dev/ttya).");
variables, especially since GDB will someday have a notion of debugging
several processes. */
inferior_pid = 42000;
inferior_ptid = pid_to_ptid (42000);
/* Start the remote connection; if error (0), discard this target.
In particular, if the user quits, be sure to discard it
(we'd be in an inconsistent state otherwise). */
@ -376,7 +376,7 @@ ocd_detach (char *args, int from_tty)
/* Tell the remote machine to resume. */
void
ocd_resume (int pid, int step, enum target_signal siggnal)
ocd_resume (ptid_t ptid, int step, enum target_signal siggnal)
{
int pktlen;
@ -1251,7 +1251,7 @@ ocd_load (char *args, int from_tty)
{
generic_load (args, from_tty);
inferior_pid = 0;
inferior_ptid = null_ptid;
/* This is necessary because many things were based on the PC at the time that
we attached to the monitor, which is no longer valid now that we have loaded

View File

@ -93,7 +93,7 @@ void ocd_close (int quitting);
void ocd_detach (char *args, int from_tty);
void ocd_resume (int pid, int step, enum target_signal siggnal);
void ocd_resume (ptid_t ptid, int step, enum target_signal siggnal);
void ocd_prepare_to_store (void);
@ -111,7 +111,7 @@ void ocd_mourn (void);
void ocd_create_inferior (char *exec_file, char *args, char **env);
int ocd_thread_alive (int th);
int ocd_thread_alive (ptid_t th);
void ocd_error (char *s, int error_code);

View File

@ -876,7 +876,7 @@ solib_create_inferior_hook (void)
stop_signal = TARGET_SIGNAL_0;
do
{
target_resume (-1, 0, stop_signal);
target_resume (minus_one_ptid, 0, stop_signal);
wait_for_inferior ();
}
while (stop_signal != TARGET_SIGNAL_TRAP);

View File

@ -40,7 +40,8 @@
static void bdm_ppc_open (char *name, int from_tty);
static int bdm_ppc_wait (int pid, struct target_waitstatus *target_status);
static ptid_t bdm_ppc_wait (ptid_t ptid,
struct target_waitstatus *target_status);
static void bdm_ppc_fetch_registers (int regno);
@ -97,8 +98,8 @@ bdm_ppc_open (char *name, int from_tty)
Returns "pid" (though it's not clear what, if anything, that
means in the case of this target). */
static int
bdm_ppc_wait (int pid, struct target_waitstatus *target_status)
static ptid_t
bdm_ppc_wait (ptid_t ptid, struct target_waitstatus *target_status)
{
int stop_reason;
@ -109,7 +110,7 @@ bdm_ppc_wait (int pid, struct target_waitstatus *target_status)
if (stop_reason)
{
target_status->value.sig = TARGET_SIGNAL_INT;
return inferior_pid;
return inferior_ptid;
}
target_status->value.sig = TARGET_SIGNAL_TRAP; /* XXX for now */
@ -124,7 +125,7 @@ bdm_ppc_wait (int pid, struct target_waitstatus *target_status)
}
#endif
return inferior_pid;
return inferior_ptid;
}
static int bdm_regmap[] =

View File

@ -45,7 +45,7 @@ fetch_inferior_registers (int regno)
#endif
int i;
ptrace (PT_GETREGS, inferior_pid,
ptrace (PT_GETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers, 0);
for (i = 0; i < 32; i++)
RF (i, inferior_registers.fixreg[i]);
@ -56,7 +56,7 @@ fetch_inferior_registers (int regno)
RF (PC_REGNUM, inferior_registers.pc);
#ifdef PT_GETFPREGS
ptrace (PT_GETFPREGS, inferior_pid,
ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
for (i = 0; i < 32; i++)
RF (FP0_REGNUM + i, inferior_fp_registers.fpreg[i]);
@ -82,13 +82,13 @@ store_inferior_registers (int regno)
RS (PPC_CTR_REGNUM, inferior_registers.ctr);
RS (PC_REGNUM, inferior_registers.pc);
ptrace (PT_SETREGS, inferior_pid,
ptrace (PT_SETREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_registers, 0);
#ifdef PT_SETFPREGS
for (i = 0; i < 32; i++)
RS (FP0_REGNUM + i, inferior_fp_registers.fpreg[i]);
ptrace (PT_SETFPREGS, inferior_pid,
ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) & inferior_fp_registers, 0);
#endif
}

View File

@ -61,21 +61,21 @@ typedef size_t gdb_ps_size_t;
/* Helper functions. */
static void
restore_inferior_pid (void *arg)
restore_inferior_ptid (void *arg)
{
int *saved_pid_ptr = arg;
inferior_pid = *saved_pid_ptr;
ptid_t *saved_pid_ptr = arg;
inferior_ptid = *saved_pid_ptr;
xfree (arg);
}
static struct cleanup *
save_inferior_pid (void)
save_inferior_ptid (void)
{
int *saved_pid_ptr;
ptid_t *saved_ptid_ptr;
saved_pid_ptr = xmalloc (sizeof (int));
*saved_pid_ptr = inferior_pid;
return make_cleanup (restore_inferior_pid, saved_pid_ptr);
saved_ptid_ptr = xmalloc (sizeof (ptid_t));
*saved_ptid_ptr = inferior_ptid;
return make_cleanup (restore_inferior_ptid, saved_ptid_ptr);
}
/* Transfer LEN bytes of memory between BUF and address ADDR in the
@ -90,10 +90,10 @@ static ps_err_e
ps_xfer_memory (const struct ps_prochandle *ph, paddr_t addr,
char *buf, size_t len, int write)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
int ret;
inferior_pid = ph->pid;
inferior_ptid = pid_to_ptid (ph->pid);
if (write)
ret = target_write_memory (addr, buf, len);
@ -250,9 +250,9 @@ ps_ptwrite (gdb_ps_prochandle_t ph, paddr_t addr,
ps_err_e
ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
inferior_pid = BUILD_LWP (lwpid, ph->pid);
inferior_ptid = BUILD_LWP (lwpid, ph->pid);
target_fetch_registers (-1);
fill_gregset ((gdb_gregset_t *) gregset, -1);
@ -267,9 +267,9 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
ps_err_e
ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
inferior_pid = BUILD_LWP (lwpid, ph->pid);
inferior_ptid = BUILD_LWP (lwpid, ph->pid);
/* FIXME: We should really make supply_gregset const-correct. */
supply_gregset ((gdb_gregset_t *) gregset);
@ -286,9 +286,9 @@ ps_err_e
ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
gdb_prfpregset_t *fpregset)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
inferior_pid = BUILD_LWP (lwpid, ph->pid);
inferior_ptid = BUILD_LWP (lwpid, ph->pid);
target_fetch_registers (-1);
fill_fpregset ((gdb_fpregset_t *) fpregset, -1);
@ -304,9 +304,9 @@ ps_err_e
ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
const gdb_prfpregset_t *fpregset)
{
struct cleanup *old_chain = save_inferior_pid ();
struct cleanup *old_chain = save_inferior_ptid ();
inferior_pid = BUILD_LWP (lwpid, ph->pid);
inferior_ptid = BUILD_LWP (lwpid, ph->pid);
/* FIXME: We should really make supply_fpregset const-correct. */
supply_fpregset ((gdb_fpregset_t *) fpregset);

View File

@ -106,26 +106,26 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
static void procfs_open (char *, int);
static void procfs_attach (char *, int);
static void procfs_detach (char *, int);
static void procfs_resume (int, int, enum target_signal);
static void procfs_resume (ptid_t, int, enum target_signal);
static int procfs_can_run (void);
static void procfs_stop (void);
static void procfs_files_info (struct target_ops *);
static void procfs_fetch_registers (int);
static void procfs_store_registers (int);
static void procfs_notice_signals (int);
static void procfs_notice_signals (ptid_t);
static void procfs_prepare_to_store (void);
static void procfs_kill_inferior (void);
static void procfs_mourn_inferior (void);
static void procfs_create_inferior (char *, char *, char **);
static int procfs_wait (int, struct target_waitstatus *);
static ptid_t procfs_wait (ptid_t, struct target_waitstatus *);
static int procfs_xfer_memory (CORE_ADDR, char *, int, int,
struct mem_attrib *attrib,
struct target_ops *);
static int procfs_thread_alive (int);
static int procfs_thread_alive (ptid_t);
void procfs_find_new_threads (void);
char *procfs_pid_to_str (int);
char *procfs_pid_to_str (ptid_t);
struct target_ops procfs_ops; /* the target vector */
@ -2904,7 +2904,7 @@ proc_iterate_over_mappings (int (*func) (int, CORE_ADDR))
int funcstat = 0;
int fd;
pi = find_procinfo_or_die (PIDGET (inferior_pid), 0);
pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
#ifdef NEW_PROC_API
/* Open map fd. */
@ -3450,7 +3450,7 @@ proc_iterate_over_threads (procinfo *pi,
* Here are all of the gdb target vector functions and their friends.
*/
static int do_attach (int pid);
static ptid_t do_attach (ptid_t ptid);
static void do_detach (int signo);
static int register_gdb_signals (procinfo *, gdb_sigset_t *);
@ -3602,13 +3602,14 @@ procfs_attach (char *args, int from_tty)
if (exec_file)
printf_filtered ("Attaching to program `%s', %s\n",
exec_file, target_pid_to_str (pid));
exec_file, target_pid_to_str (pid_to_ptid (pid)));
else
printf_filtered ("Attaching to %s\n", target_pid_to_str (pid));
printf_filtered ("Attaching to %s\n",
target_pid_to_str (pid_to_ptid (pid)));
fflush (stdout);
}
inferior_pid = do_attach (pid);
inferior_ptid = do_attach (pid_to_ptid (pid));
push_target (&procfs_ops);
}
@ -3624,31 +3625,31 @@ procfs_detach (char *args, int from_tty)
if (exec_file == 0)
exec_file = "";
printf_filtered ("Detaching from program: %s %s\n",
exec_file, target_pid_to_str (inferior_pid));
exec_file, target_pid_to_str (inferior_ptid));
fflush (stdout);
}
if (args)
signo = atoi (args);
do_detach (signo);
inferior_pid = 0;
inferior_ptid = null_ptid;
unpush_target (&procfs_ops); /* Pop out of handling an inferior */
}
static int
do_attach (int pid)
static ptid_t
do_attach (ptid_t ptid)
{
procinfo *pi;
int fail;
if ((pi = create_procinfo (pid, 0)) == NULL)
if ((pi = create_procinfo (PIDGET (ptid), 0)) == NULL)
perror ("procfs: out of memory in 'attach'");
if (!open_procinfo_files (pi, FD_CTL))
{
fprintf_filtered (gdb_stderr, "procfs:%d -- ", __LINE__);
sprintf (errmsg, "do_attach: couldn't open /proc file for process %d",
pid);
PIDGET (ptid));
dead_procinfo (pi, errmsg, NOKILL);
}
@ -3698,7 +3699,7 @@ do_detach (int signo)
procinfo *pi;
/* Find procinfo for the main process */
pi = find_procinfo_or_die (PIDGET (inferior_pid), 0); /* FIXME: threads */
pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); /* FIXME: threads */
if (signo)
if (!proc_set_current_signal (pi, signo))
proc_warn (pi, "do_detach, set_current_signal", __LINE__);
@ -3754,14 +3755,14 @@ procfs_fetch_registers (int regno)
int pid;
int tid;
pid = PIDGET (inferior_pid);
tid = TIDGET (inferior_pid);
pid = PIDGET (inferior_ptid);
tid = TIDGET (inferior_ptid);
/* First look up procinfo for the main process. */
pi = find_procinfo_or_die (pid, 0);
/* If the event thread is not the same as GDB's requested thread
(ie. inferior_pid), then look up procinfo for the requested
(ie. inferior_ptid), then look up procinfo for the requested
thread. */
if ((tid != 0) &&
(tid != proc_get_current_thread (pi)))
@ -3769,7 +3770,7 @@ procfs_fetch_registers (int regno)
if (pi == NULL)
error ("procfs: fetch_registers failed to find procinfo for %s",
target_pid_to_str (inferior_pid));
target_pid_to_str (inferior_ptid));
if ((gregs = proc_get_gregs (pi)) == NULL)
proc_error (pi, "fetch_registers, get_gregs", __LINE__);
@ -3826,14 +3827,14 @@ procfs_store_registers (int regno)
int pid;
int tid;
pid = PIDGET (inferior_pid);
tid = TIDGET (inferior_pid);
pid = PIDGET (inferior_ptid);
tid = TIDGET (inferior_ptid);
/* First find procinfo for main process */
pi = find_procinfo_or_die (pid, 0);
/* If current lwp for process is not the same as requested thread
(ie. inferior_pid), then find procinfo for the requested thread. */
(ie. inferior_ptid), then find procinfo for the requested thread. */
if ((tid != 0) &&
(tid != proc_get_current_thread (pi)))
@ -3841,7 +3842,7 @@ procfs_store_registers (int regno)
if (pi == NULL)
error ("procfs: store_registers: failed to find procinfo for %s",
target_pid_to_str (inferior_pid));
target_pid_to_str (inferior_ptid));
if ((gregs = proc_get_gregs (pi)) == NULL)
proc_error (pi, "store_registers, get_gregs", __LINE__);
@ -3947,13 +3948,14 @@ syscall_is_lwp_create (procinfo *pi, int scall)
* event codes are returned thru a pointer parameter.
*/
static int
procfs_wait (int pid, struct target_waitstatus *status)
static ptid_t
procfs_wait (ptid_t ptid, struct target_waitstatus *status)
{
/* First cut: loosely based on original version 2.1 */
procinfo *pi;
int temp, wstat;
int retval;
int wstat;
int temp_tid;
ptid_t retval, temp_ptid;
int why, what, flags;
int retry = 0;
@ -3961,10 +3963,10 @@ wait_again:
retry++;
wstat = 0;
retval = -1;
retval = pid_to_ptid (-1);
/* Find procinfo for main process */
pi = find_procinfo_or_die (PIDGET (inferior_pid), 0);
pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
if (pi)
{
/* We must assume that the status is stale now... */
@ -3985,14 +3987,17 @@ wait_again:
/* wait_for_stop failed: has the child terminated? */
if (errno == ENOENT)
{
/* /proc file not found; presumably child has terminated. */
retval = wait (&wstat); /* "wait" for the child's exit */
int wait_retval;
if (retval != PIDGET (inferior_pid)) /* wrong child? */
/* /proc file not found; presumably child has terminated. */
wait_retval = wait (&wstat); /* "wait" for the child's exit */
if (wait_retval != PIDGET (inferior_ptid)) /* wrong child? */
error ("procfs: couldn't stop process %d: wait returned %d\n",
inferior_pid, retval);
PIDGET (inferior_ptid), wait_retval);
/* FIXME: might I not just use waitpid?
Or try find_procinfo to see if I know about this child? */
retval = pid_to_ptid (wait_retval);
}
else if (errno == EINTR)
goto wait_again;
@ -4069,7 +4074,7 @@ wait_again:
return a "success" exit code. Bogus: what if
it returns something else? */
wstat = 0;
retval = inferior_pid; /* ? ? ? */
retval = inferior_ptid; /* ? ? ? */
}
else
{
@ -4084,7 +4089,7 @@ wait_again:
/* If wait returns -1, that's what we return to GDB. */
if (temp < 0)
retval = temp;
retval = pid_to_ptid (temp);
}
}
else
@ -4111,12 +4116,12 @@ wait_again:
{
/* How to exit gracefully, returning "unknown event" */
status->kind = TARGET_WAITKIND_SPURIOUS;
return inferior_pid;
return inferior_ptid;
}
else
{
/* How to keep going without returning to wfi: */
target_resume (pid, 0, TARGET_SIGNAL_0);
target_resume (ptid, 0, TARGET_SIGNAL_0);
goto wait_again;
}
}
@ -4142,20 +4147,21 @@ wait_again:
*/
/* If not in procinfo list, add it. */
temp = proc_get_current_thread (pi);
if (!find_procinfo (pi->pid, temp))
create_procinfo (pi->pid, temp);
temp_tid = proc_get_current_thread (pi);
if (!find_procinfo (pi->pid, temp_tid))
create_procinfo (pi->pid, temp_tid);
temp = MERGEPID (pi->pid, temp);
temp_ptid = MERGEPID (pi->pid, temp_tid);
/* If not in GDB's thread list, add it. */
if (!in_thread_list (temp))
if (!in_thread_list (temp_ptid))
{
printf_filtered ("[New %s]\n", target_pid_to_str (temp));
add_thread (temp);
printf_filtered ("[New %s]\n",
target_pid_to_str (temp_ptid));
add_thread (temp_ptid);
}
/* Return to WFI, but tell it to immediately resume. */
status->kind = TARGET_WAITKIND_SPURIOUS;
return inferior_pid;
return inferior_ptid;
}
else if (syscall_is_lwp_exit (pi, what))
{
@ -4194,7 +4200,7 @@ wait_again:
}
#endif
status->kind = TARGET_WAITKIND_SPURIOUS;
return inferior_pid;
return inferior_ptid;
}
break;
case PR_REQUESTED:
@ -4211,17 +4217,17 @@ wait_again:
else
{
/* If not in procinfo list, add it. */
temp = proc_get_current_thread (pi);
if (!find_procinfo (pi->pid, temp))
create_procinfo (pi->pid, temp);
temp_tid = proc_get_current_thread (pi);
if (!find_procinfo (pi->pid, temp_tid))
create_procinfo (pi->pid, temp_tid);
/* If not in GDB's thread list, add it. */
temp = MERGEPID (pi->pid, temp);
if (!in_thread_list (temp))
temp_ptid = MERGEPID (pi->pid, temp_tid);
if (!in_thread_list (temp_ptid))
{
printf_filtered ("[New %s]\n",
target_pid_to_str (temp));
add_thread (temp);
target_pid_to_str (temp_ptid));
add_thread (temp_ptid);
}
status->kind = TARGET_WAITKIND_STOPPED;
@ -4273,7 +4279,7 @@ wait_again:
break;
case FLTPAGE: /* Recoverable page fault */
default: /* FIXME: use si_signo if possible for fault */
retval = -1;
retval = pid_to_ptid (-1);
printf_filtered ("procfs:%d -- ", __LINE__);
printf_filtered ("child stopped for unknown reason:\n");
proc_prettyprint_why (why, what, 1);
@ -4292,8 +4298,8 @@ wait_again:
* Got this far without error:
* If retval isn't in the threads database, add it.
*/
if (retval > 0 &&
retval != inferior_pid &&
if (PIDGET (retval) > 0 &&
!ptid_equal (retval, inferior_ptid) &&
!in_thread_list (retval))
{
/*
@ -4309,16 +4315,16 @@ wait_again:
/* In addition, it's possible that this is the first
* new thread we've seen, in which case we may not
* have created entries for inferior_pid yet.
* have created entries for inferior_ptid yet.
*/
if (TIDGET (inferior_pid) != 0)
if (TIDGET (inferior_ptid) != 0)
{
if (!in_thread_list (inferior_pid))
add_thread (inferior_pid);
if (find_procinfo (PIDGET (inferior_pid),
TIDGET (inferior_pid)) == NULL)
create_procinfo (PIDGET (inferior_pid),
TIDGET (inferior_pid));
if (!in_thread_list (inferior_ptid))
add_thread (inferior_ptid);
if (find_procinfo (PIDGET (inferior_ptid),
TIDGET (inferior_ptid)) == NULL)
create_procinfo (PIDGET (inferior_ptid),
TIDGET (inferior_ptid));
}
}
}
@ -4357,7 +4363,7 @@ procfs_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int dowrite,
int nbytes = 0;
/* Find procinfo for main process */
pi = find_procinfo_or_die (PIDGET (inferior_pid), 0);
pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
if (pi->as_fd == 0 &&
open_procinfo_files (pi, FD_AS) == 0)
{
@ -4495,7 +4501,7 @@ make_signal_thread_runnable (procinfo *process, procinfo *pi, void *ptr)
*/
static void
procfs_resume (int pid, int step, enum target_signal signo)
procfs_resume (ptid_t ptid, int step, enum target_signal signo)
{
procinfo *pi, *thread;
int native_signo;
@ -4517,7 +4523,7 @@ procfs_resume (int pid, int step, enum target_signal signo)
to proc_run_process (for use in the prrun struct by ioctl). */
/* Find procinfo for main process */
pi = find_procinfo_or_die (PIDGET (inferior_pid), 0);
pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
/* First cut: ignore pid argument */
errno = 0;
@ -4537,13 +4543,13 @@ procfs_resume (int pid, int step, enum target_signal signo)
/* Void the process procinfo's caches. */
invalidate_cache (NULL, pi, NULL);
if (pid != -1)
if (PIDGET (ptid) != -1)
{
/* Resume a specific thread, presumably suppressing the others. */
thread = find_procinfo (PIDGET (pid), TIDGET (pid));
thread = find_procinfo (PIDGET (ptid), TIDGET (ptid));
if (thread == NULL)
warning ("procfs: resume can't find thread %d -- resuming all.",
TIDGET (pid));
warning ("procfs: resume can't find thread %ld -- resuming all.",
TIDGET (ptid));
else
{
if (thread->tid != 0)
@ -4607,10 +4613,10 @@ register_gdb_signals (procinfo *pi, gdb_sigset_t *signals)
*/
static void
procfs_notice_signals (int pid)
procfs_notice_signals (ptid_t ptid)
{
gdb_sigset_t signals;
procinfo *pi = find_procinfo_or_die (PIDGET (pid), 0);
procinfo *pi = find_procinfo_or_die (PIDGET (ptid), 0);
if (proc_get_traced_signals (pi, &signals) &&
register_gdb_signals (pi, &signals))
@ -4630,7 +4636,7 @@ procfs_files_info (struct target_ops *ignore)
{
printf_filtered ("\tUsing the running image of %s %s via /proc.\n",
attach_flag? "attached": "child",
target_pid_to_str (inferior_pid));
target_pid_to_str (inferior_ptid));
}
/*
@ -4762,10 +4768,10 @@ unconditionally_kill_inferior (procinfo *pi)
static void
procfs_kill_inferior (void)
{
if (inferior_pid != 0) /* ? */
if (!ptid_equal (inferior_ptid, null_ptid)) /* ? */
{
/* Find procinfo for main process */
procinfo *pi = find_procinfo (PIDGET (inferior_pid), 0);
procinfo *pi = find_procinfo (PIDGET (inferior_ptid), 0);
if (pi)
unconditionally_kill_inferior (pi);
@ -4784,10 +4790,10 @@ procfs_mourn_inferior (void)
{
procinfo *pi;
if (inferior_pid != 0)
if (!ptid_equal (inferior_ptid, null_ptid))
{
/* Find procinfo for main process */
pi = find_procinfo (PIDGET (inferior_pid), 0);
pi = find_procinfo (PIDGET (inferior_ptid), 0);
if (pi)
destroy_procinfo (pi);
}
@ -4872,7 +4878,7 @@ procfs_init_inferior (int pid)
/* The 'process ID' we return to GDB is composed of
the actual process ID plus the lwp ID. */
inferior_pid = MERGEPID (pi->pid, proc_get_current_thread (pi));
inferior_ptid = MERGEPID (pi->pid, proc_get_current_thread (pi));
#ifdef START_INFERIOR_TRAPS_EXPECTED
startup_inferior (START_INFERIOR_TRAPS_EXPECTED);
@ -5101,7 +5107,7 @@ procfs_create_inferior (char *exec_file, char *allargs, char **env)
static int
procfs_notice_thread (procinfo *pi, procinfo *thread, void *ptr)
{
int gdb_threadid = MERGEPID (pi->pid, thread->tid);
ptid_t gdb_threadid = MERGEPID (pi->pid, thread->tid);
if (!in_thread_list (gdb_threadid))
add_thread (gdb_threadid);
@ -5122,7 +5128,7 @@ procfs_find_new_threads (void)
procinfo *pi;
/* Find procinfo for main process */
pi = find_procinfo_or_die (PIDGET (inferior_pid), 0);
pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
proc_update_threads (pi);
proc_iterate_over_threads (pi, procfs_notice_thread, NULL);
}
@ -5137,13 +5143,13 @@ procfs_find_new_threads (void)
*/
static int
procfs_thread_alive (int pid)
procfs_thread_alive (ptid_t ptid)
{
int proc, thread;
procinfo *pi;
proc = PIDGET (pid);
thread = TIDGET (pid);
proc = PIDGET (ptid);
thread = TIDGET (ptid);
/* If I don't know it, it ain't alive! */
if ((pi = find_procinfo (proc, thread)) == NULL)
return 0;
@ -5167,14 +5173,14 @@ procfs_thread_alive (int pid)
*/
char *
procfs_pid_to_str (int pid)
procfs_pid_to_str (ptid_t ptid)
{
static char buf[80];
int proc, thread;
procinfo *pi;
proc = PIDGET (pid);
thread = TIDGET (pid);
proc = PIDGET (ptid);
thread = TIDGET (ptid);
pi = find_procinfo (proc, thread);
if (thread == 0)
@ -5190,15 +5196,16 @@ procfs_pid_to_str (int pid)
*/
int
procfs_set_watchpoint (int pid, CORE_ADDR addr, int len, int rwflag, int after)
procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag,
int after)
{
#ifndef UNIXWARE
#ifndef AIX5
int pflags = 0;
procinfo *pi;
pi = find_procinfo_or_die (pid == -1 ?
PIDGET (inferior_pid) : PIDGET (pid), 0);
pi = find_procinfo_or_die (PIDGET (ptid) == -1 ?
PIDGET (inferior_ptid) : PIDGET (ptid), 0);
/* Translate from GDB's flags to /proc's */
if (len > 0) /* len == 0 means delete watchpoint */
@ -5246,12 +5253,12 @@ procfs_set_watchpoint (int pid, CORE_ADDR addr, int len, int rwflag, int after)
*/
int
procfs_stopped_by_watchpoint (int pid)
procfs_stopped_by_watchpoint (ptid_t ptid)
{
procinfo *pi;
pi = find_procinfo (pid == -1 ?
PIDGET (inferior_pid) : PIDGET (pid), 0);
pi = find_procinfo_or_die (PIDGET (ptid) == -1 ?
PIDGET (inferior_ptid) : PIDGET (ptid), 0);
if (!pi) /* If no process, then not stopped by watchpoint! */
return 0;
@ -5278,31 +5285,31 @@ procfs_stopped_by_watchpoint (int pid)
* Function: procfs_find_LDT_entry
*
* Input:
* int pid; // The GDB-style pid-plus-LWP.
* ptid_t ptid; // The GDB-style pid-plus-LWP.
*
* Return:
* pointer to the corresponding LDT entry.
*/
struct ssd *
procfs_find_LDT_entry (int pid)
procfs_find_LDT_entry (ptid_t ptid)
{
gdb_gregset_t *gregs;
int key;
procinfo *pi;
/* Find procinfo for the lwp. */
if ((pi = find_procinfo (PIDGET (pid), TIDGET (pid))) == NULL)
if ((pi = find_procinfo (PIDGET (ptid), TIDGET (ptid))) == NULL)
{
warning ("procfs_find_LDT_entry: could not find procinfi for %d.",
pid);
warning ("procfs_find_LDT_entry: could not find procinfo for %d:%d.",
PIDGET (ptid), TIDGET (ptid));
return NULL;
}
/* get its general registers. */
if ((gregs = proc_get_gregs (pi)) == NULL)
{
warning ("procfs_find_LDT_entry: could not read gregs for %d.",
pid);
warning ("procfs_find_LDT_entry: could not read gregs for %d:%d.",
PIDGET (ptid), TIDGET (ptid));
return NULL;
}
/* Now extract the GS register's lower 16 bits. */
@ -5353,7 +5360,7 @@ info_proc_cmd (char *args, int from_tty)
argv++;
}
if (pid == 0)
pid = PIDGET (inferior_pid);
pid = PIDGET (inferior_ptid);
if (pid == 0)
error ("No current process: you must name one.");
else
@ -5402,13 +5409,13 @@ proc_trace_syscalls (char *args, int from_tty, int entry_or_exit, int mode)
sysset_t *sysset;
int syscallnum = 0;
if (inferior_pid <= 0)
if (PIDGET (inferior_ptid) <= 0)
error ("you must be debugging a process to use this command.");
if (args == NULL || args[0] == 0)
error_no_arg ("system call to trace");
pi = find_procinfo_or_die (PIDGET (inferior_pid), 0);
pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
if (isdigit (args[0]))
{
syscallnum = atoi (args);
@ -5495,11 +5502,8 @@ Default is the process being debugged.");
* we will be able to find a 'live' procinfo.
*/
int
ptid_t
procfs_first_available (void)
{
if (procinfo_list)
return procinfo_list->pid;
else
return -1;
return pid_to_ptid (procinfo_list ? procinfo_list->pid : -1);
}

View File

@ -153,7 +153,7 @@ proc_iterate_over_mappings (int (*func) (int, CORE_ADDR))
curseg = 0;
while (1)
{
rv = ptrace (PT_NEXT_VSEG, inferior_pid, &pv, curseg);
rv = ptrace (PT_NEXT_VSEG, PIDGET (inferior_ptid), &pv, curseg);
#ifdef VERBOSE_DEBUG
printf ("PT_NEXT_VSEG: rv %d errno %d\n", rv, errno);
#endif
@ -187,7 +187,7 @@ proc_iterate_over_mappings (int (*func) (int, CORE_ADDR))
close (interp_fd);
return 0;
}
rv = ptrace (PT_RDATA_PAGE, inferior_pid, buf2,
rv = ptrace (PT_RDATA_PAGE, PIDGET (inferior_ptid), buf2,
memptr);
if (-1 == rv)
{

View File

@ -49,10 +49,9 @@ char *registers;
signed char *register_valid;
/* The thread/process associated with the current set of registers.
For now, -1 is special, and means `no current process'. */
/* The thread/process associated with the current set of registers. */
static int registers_pid = -1;
static ptid_t registers_ptid;
/*
* FUNCTIONS:
@ -154,7 +153,7 @@ registers_changed (void)
{
int i;
registers_pid = -1;
registers_ptid = pid_to_ptid (-1);
/* Force cleanup of any alloca areas if using C alloca instead of
a builtin alloca. This particular call is used to clean up
@ -280,10 +279,10 @@ static void
legacy_read_register_gen (int regnum, char *myaddr)
{
gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS));
if (registers_pid != inferior_pid)
if (! ptid_equal (registers_ptid, inferior_ptid))
{
registers_changed ();
registers_pid = inferior_pid;
registers_ptid = inferior_ptid;
}
if (!register_cached (regnum))
@ -332,10 +331,10 @@ legacy_write_register_gen (int regnum, char *myaddr)
if (CANNOT_STORE_REGISTER (regnum))
return;
if (registers_pid != inferior_pid)
if (! ptid_equal (registers_ptid, inferior_ptid))
{
registers_changed ();
registers_pid = inferior_pid;
registers_ptid = inferior_ptid;
}
size = REGISTER_RAW_SIZE (regnum);
@ -440,21 +439,22 @@ read_register (int regnum)
}
ULONGEST
read_register_pid (int regnum, int pid)
read_register_pid (int regnum, ptid_t ptid)
{
ptid_t save_ptid;
int save_pid;
CORE_ADDR retval;
if (pid == inferior_pid)
if (ptid_equal (ptid, inferior_ptid))
return read_register (regnum);
save_pid = inferior_pid;
save_ptid = inferior_ptid;
inferior_pid = pid;
inferior_ptid = ptid;
retval = read_register (regnum);
inferior_pid = save_pid;
inferior_ptid = save_ptid;
return retval;
}
@ -470,21 +470,21 @@ read_signed_register (int regnum)
}
LONGEST
read_signed_register_pid (int regnum, int pid)
read_signed_register_pid (int regnum, ptid_t ptid)
{
int save_pid;
ptid_t save_ptid;
LONGEST retval;
if (pid == inferior_pid)
if (ptid_equal (ptid, inferior_ptid))
return read_signed_register (regnum);
save_pid = inferior_pid;
save_ptid = inferior_ptid;
inferior_pid = pid;
inferior_ptid = ptid;
retval = read_signed_register (regnum);
inferior_pid = save_pid;
inferior_ptid = save_ptid;
return retval;
}
@ -503,23 +503,23 @@ write_register (int regnum, LONGEST val)
}
void
write_register_pid (int regnum, CORE_ADDR val, int pid)
write_register_pid (int regnum, CORE_ADDR val, ptid_t ptid)
{
int save_pid;
ptid_t save_ptid;
if (pid == inferior_pid)
if (ptid_equal (ptid, inferior_ptid))
{
write_register (regnum, val);
return;
}
save_pid = inferior_pid;
save_ptid = inferior_ptid;
inferior_pid = pid;
inferior_ptid = ptid;
write_register (regnum, val);
inferior_pid = save_pid;
inferior_ptid = save_ptid;
}
/* SUPPLY_REGISTER()
@ -536,10 +536,10 @@ void
supply_register (int regnum, char *val)
{
#if 1
if (registers_pid != inferior_pid)
if (! ptid_equal (registers_ptid, inferior_ptid))
{
registers_changed ();
registers_pid = inferior_pid;
registers_ptid = inferior_ptid;
}
#endif
@ -590,12 +590,12 @@ supply_register (int regnum, char *val)
TARGET_READ_PC directly. (cagney). */
CORE_ADDR
generic_target_read_pc (int pid)
generic_target_read_pc (ptid_t ptid)
{
#ifdef PC_REGNUM
if (PC_REGNUM >= 0)
{
CORE_ADDR pc_val = ADDR_BITS_REMOVE ((CORE_ADDR) read_register_pid (PC_REGNUM, pid));
CORE_ADDR pc_val = ADDR_BITS_REMOVE ((CORE_ADDR) read_register_pid (PC_REGNUM, ptid));
return pc_val;
}
#endif
@ -605,37 +605,37 @@ generic_target_read_pc (int pid)
}
CORE_ADDR
read_pc_pid (int pid)
read_pc_pid (ptid_t ptid)
{
int saved_inferior_pid;
ptid_t saved_inferior_ptid;
CORE_ADDR pc_val;
/* In case pid != inferior_pid. */
saved_inferior_pid = inferior_pid;
inferior_pid = pid;
/* In case ptid != inferior_ptid. */
saved_inferior_ptid = inferior_ptid;
inferior_ptid = ptid;
pc_val = TARGET_READ_PC (pid);
pc_val = TARGET_READ_PC (ptid);
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
return pc_val;
}
CORE_ADDR
read_pc (void)
{
return read_pc_pid (inferior_pid);
return read_pc_pid (inferior_ptid);
}
void
generic_target_write_pc (CORE_ADDR pc, int pid)
generic_target_write_pc (CORE_ADDR pc, ptid_t ptid)
{
#ifdef PC_REGNUM
if (PC_REGNUM >= 0)
write_register_pid (PC_REGNUM, pc, pid);
write_register_pid (PC_REGNUM, pc, ptid);
if (NPC_REGNUM >= 0)
write_register_pid (NPC_REGNUM, pc + 4, pid);
write_register_pid (NPC_REGNUM, pc + 4, ptid);
if (NNPC_REGNUM >= 0)
write_register_pid (NNPC_REGNUM, pc + 8, pid);
write_register_pid (NNPC_REGNUM, pc + 8, ptid);
#else
internal_error (__FILE__, __LINE__,
"generic_target_write_pc");
@ -643,23 +643,23 @@ generic_target_write_pc (CORE_ADDR pc, int pid)
}
void
write_pc_pid (CORE_ADDR pc, int pid)
write_pc_pid (CORE_ADDR pc, ptid_t ptid)
{
int saved_inferior_pid;
ptid_t saved_inferior_ptid;
/* In case pid != inferior_pid. */
saved_inferior_pid = inferior_pid;
inferior_pid = pid;
/* In case ptid != inferior_ptid. */
saved_inferior_ptid = inferior_ptid;
inferior_ptid = ptid;
TARGET_WRITE_PC (pc, pid);
TARGET_WRITE_PC (pc, ptid);
inferior_pid = saved_inferior_pid;
inferior_ptid = saved_inferior_ptid;
}
void
write_pc (CORE_ADDR pc)
{
write_pc_pid (pc, inferior_pid);
write_pc_pid (pc, inferior_ptid);
}
/* Cope with strage ways of getting to the stack and frame pointers */
@ -774,4 +774,8 @@ _initialize_regcache (void)
add_com ("flushregs", class_maintenance, reg_flush_command,
"Force gdb to flush its register cache (maintainer command)");
/* Initialize the thread/process associated with the current set of
registers. For now, -1 is special, and means `no current process'. */
registers_ptid = pid_to_ptid (-1);
}

View File

@ -66,15 +66,15 @@ extern void write_register_bytes (int regbyte, char *myaddr, int len);
extern ULONGEST read_register (int regnum);
/* Rename to read_unsigned_register_pid()? */
extern ULONGEST read_register_pid (int regnum, int pid);
extern ULONGEST read_register_pid (int regnum, ptid_t ptid);
extern LONGEST read_signed_register (int regnum);
extern LONGEST read_signed_register_pid (int regnum, int pid);
extern LONGEST read_signed_register_pid (int regnum, ptid_t ptid);
extern void write_register (int regnum, LONGEST val);
extern void write_register_pid (int regnum, CORE_ADDR val, int pid);
extern void write_register_pid (int regnum, CORE_ADDR val, ptid_t ptid);
extern void supply_register (int regnum, char *val);

View File

@ -753,7 +753,7 @@ adapt_detach (char *args, int from_tty)
/* Tell the remote machine to resume. */
void
adapt_resume (int pid, int step, enum target_signal sig)
adapt_resume (ptid_t ptid, int step, enum target_signal sig)
{
if (step)
{
@ -781,8 +781,8 @@ adapt_resume (int pid, int step, enum target_signal sig)
/* Wait until the remote machine stops, then return,
storing status in STATUS just as `wait' would. */
int
adapt_wait (struct target_waitstatus *status)
ptid_t
adapt_wait (ptid_t ptid, struct target_waitstatus *status)
{
/* Strings to look for. '?' means match any single character.
Note that with the algorithm we use, the initial character
@ -815,7 +815,7 @@ adapt_wait (struct target_waitstatus *status)
status->kind = TARGET_WAITKIND_STOPPED;
status->value.sig = TARGET_SIGNAL_TRAP;
need_artificial_trap--;
return 0;
return inferior_ptid;
}
timeout = 0; /* Don't time out -- user program is running. */
@ -871,7 +871,7 @@ adapt_wait (struct target_waitstatus *status)
}
timeout = old_timeout;
immediate_quit = old_immediate_quit;
return 0;
return inferior_ptid;
}
/* Return the name of register number REGNO

View File

@ -67,7 +67,7 @@ static void array_open ();
static void array_close ();
static void array_detach ();
static void array_attach ();
static void array_resume ();
static void array_resume (ptid_t ptid, int step, enum target_signal sig);
static void array_fetch_register ();
static void array_store_register ();
static void array_fetch_registers ();
@ -79,7 +79,8 @@ static void array_create_inferior ();
static void array_mourn_inferior ();
static void make_gdb_packet ();
static int array_xfer_memory ();
static int array_wait ();
static ptid_t array_wait (ptid_t ptid,
struct target_waitstatus *status);
static int array_insert_breakpoint ();
static int array_remove_breakpoint ();
static int tohex ();
@ -697,7 +698,7 @@ array_attach (char *args, int from_tty)
* array_resume -- Tell the remote machine to resume.
*/
static void
array_resume (int pid, int step, enum target_signal sig)
array_resume (ptid_t ptid, int step, enum target_signal sig)
{
debuglogs (1, "array_resume (step=%d, sig=%d)", step, sig);
@ -717,8 +718,8 @@ array_resume (int pid, int step, enum target_signal sig)
* array_wait -- Wait until the remote machine stops, then return,
* storing status in status just as `wait' would.
*/
static int
array_wait (int pid, struct target_waitstatus *status)
static ptid_t
array_wait (ptid_t ptid, struct target_waitstatus *status)
{
int old_timeout = timeout;
int result, i;
@ -784,7 +785,7 @@ array_wait (int pid, struct target_waitstatus *status)
timeout = old_timeout;
return 0;
return inferior_ptid;
}
/*

View File

@ -115,7 +115,7 @@ bug_load (char *args, int fromtty)
sr_check_open ();
inferior_pid = 0;
inferior_ptid = null_ptid;
abfd = bfd_openr (args, 0);
if (!abfd)
{
@ -232,7 +232,7 @@ bug_open (char *args, int from_tty)
/* Tell the remote machine to resume. */
void
bug_resume (int pid, int step, enum target_signal sig)
bug_resume (ptid_t ptid, int step, enum target_signal sig)
{
if (step)
{
@ -261,8 +261,8 @@ static char *wait_strings[] =
NULL,
};
int
bug_wait (int pid, struct target_waitstatus *status)
ptid_t
bug_wait (ptid_t ptid, struct target_waitstatus *status)
{
int old_timeout = sr_get_timeout ();
int old_immediate_quit = immediate_quit;
@ -325,7 +325,7 @@ bug_wait (int pid, struct target_waitstatus *status)
sr_set_timeout (old_timeout);
immediate_quit = old_immediate_quit;
return 0;
return inferior_ptid;
}
/* Return the name of register number REGNO

View File

@ -710,7 +710,7 @@ e7000_detach (char *arg, int from_tty)
/* Tell the remote machine to resume. */
static void
e7000_resume (int pid, int step, enum target_signal sigal)
e7000_resume (ptid_t ptid, int step, enum target_signal sigal)
{
if (step)
puts_e7000debug ("S\r");
@ -1645,7 +1645,7 @@ e7000_load (char *args, int from_tty)
if (exec_bfd)
write_pc (bfd_get_start_address (exec_bfd));
inferior_pid = 0; /* No process now */
inferior_ptid = null_ptid; /* No process now */
/* This is necessary because many things were based on the PC at the time that
we attached to the monitor, which is no longer valid now that we have loaded
@ -1999,8 +1999,8 @@ static char *estrings[] =
/* Wait until the remote machine stops, then return, storing status in
STATUS just as `wait' would. */
static int
e7000_wait (int pid, struct target_waitstatus *status)
static ptid_t
e7000_wait (ptid_t ptid, struct target_waitstatus *status)
{
int stop_reason;
int regno;
@ -2122,7 +2122,7 @@ e7000_wait (int pid, struct target_waitstatus *status)
internal_error (__FILE__, __LINE__, "failed internal consistency check");
}
return 0;
return inferior_ptid;
}
/* Stop the running program. */

View File

@ -520,7 +520,7 @@ eb_detach (int from_tty)
/* Tell the remote machine to resume. */
void
eb_resume (int pid, int step, enum target_signal sig)
eb_resume (ptid_t ptid, int step, enum target_signal sig)
{
if (step)
{
@ -559,8 +559,8 @@ eb_resume (int pid, int step, enum target_signal sig)
/* Wait until the remote machine stops, then return,
storing status in STATUS just as `wait' would. */
int
eb_wait (struct target_waitstatus *status)
ptid_t
eb_wait (ptid_t ptid, struct target_waitstatus *status)
{
/* Strings to look for. '?' means match any single character.
Note that with the algorithm we use, the initial character

View File

@ -140,9 +140,9 @@ es1800_xfer_inferior_memory (CORE_ADDR, char *, int, int,
static void es1800_prepare_to_store (void);
static int es1800_wait (int, struct target_waitstatus *);
static ptid_t es1800_wait (ptid_t, struct target_waitstatus *);
static void es1800_resume (int, int, enum target_signal);
static void es1800_resume (ptid_t, int, enum target_signal);
static void es1800_detach (char *, int);
@ -500,7 +500,7 @@ es1800_detach (char *args, int from_tty)
siggnal - the signal value to be given to the target (0 = no signal) */
static void
es1800_resume (int pid, int step, enum target_signal siggnal)
es1800_resume (ptid_t ptid, int step, enum target_signal siggnal)
{
char buf[PBUFSIZ];
@ -523,8 +523,8 @@ es1800_resume (int pid, int step, enum target_signal siggnal)
storing status in STATUS just as `wait' would.
status - */
static int
es1800_wait (int pid, struct target_waitstatus *status)
static ptid_t
es1800_wait (ptid_t ptid, struct target_waitstatus *status)
{
unsigned char buf[PBUFSIZ];
int old_timeout = timeout;
@ -589,7 +589,7 @@ es1800_wait (int pid, struct target_waitstatus *status)
}
signal (SIGINT, old_sigint);
timeout = old_timeout;
return (0);
return inferior_ptid;
}
@ -1206,9 +1206,9 @@ get_break_addr (int vec, CORE_ADDR *addrp)
static void
es1800_kill (void)
{
if (inferior_pid != 0)
if (!ptid_equal (inferior_ptid, null_ptid))
{
inferior_pid = 0;
inferior_ptid = null_ptid;
es1800_mourn_inferior ();
}
}
@ -1273,7 +1273,7 @@ es1800_load (char *filename, int from_tty)
}
breakpoint_init_inferior ();
inferior_pid = 0;
inferior_ptid = null_ptid;
if (from_tty)
{
printf ("Downloading \"%s\" to the ES 1800\n", filename);
@ -1374,7 +1374,7 @@ bfd_copy (bfd *from_bfd, bfd *to_bfd)
#endif
/* Start an process on the es1800 and set inferior_pid to the new
/* Start an process on the es1800 and set inferior_ptid to the new
process' pid.
execfile - the file to run
args - arguments passed to the program
@ -1427,7 +1427,7 @@ es1800_create_inferior (char *execfile, char *args, char **env)
/* The "process" (board) is already stopped awaiting our commands, and
the program is already downloaded. We just set its PC and go. */
inferior_pid = pid; /* Needed for wait_for_inferior below */
inferior_ptid = pid_to_ptid (pid); /* Needed for wait_for_inferior below */
clear_proceed_status ();
@ -1961,7 +1961,7 @@ es1800_child_detach (char *args, int from_tty)
pop_target ();
if (from_tty)
{
printf ("Ending debugging the process %d.\n", inferior_pid);
printf ("Ending debugging the process %d.\n", PIDGET (inferior_ptid));
}
}

View File

@ -85,9 +85,11 @@ static void mips_close (int quitting);
static void mips_detach (char *args, int from_tty);
static void mips_resume (int pid, int step, enum target_signal siggnal);
static void mips_resume (ptid_t ptid, int step,
enum target_signal siggnal);
static int mips_wait (int pid, struct target_waitstatus *status);
static ptid_t mips_wait (ptid_t ptid,
struct target_waitstatus *status);
static int mips_map_regno (int regno);
@ -1704,7 +1706,7 @@ mips_detach (char *args, int from_tty)
where PMON does return a reply. */
static void
mips_resume (int pid, int step, enum target_signal siggnal)
mips_resume (ptid_t ptid, int step, enum target_signal siggnal)
{
int err;
@ -1736,8 +1738,8 @@ mips_signal_from_protocol (int sig)
/* Wait until the remote stops, and return a wait status. */
static int
mips_wait (int pid, struct target_waitstatus *status)
static ptid_t
mips_wait (ptid_t ptid, struct target_waitstatus *status)
{
int rstatus;
int err;
@ -1757,7 +1759,7 @@ mips_wait (int pid, struct target_waitstatus *status)
{
status->kind = TARGET_WAITKIND_STOPPED;
status->value.sig = TARGET_SIGNAL_TRAP;
return 0;
return inferior_ptid;
}
/* No timeout; we sit here as long as the program continues to execute. */
@ -1888,7 +1890,7 @@ mips_wait (int pid, struct target_waitstatus *status)
status->value.sig = mips_signal_from_protocol (rstatus & 0x7f);
}
return 0;
return inferior_ptid;
}
/* We have to map between the register numbers used by gdb and the
@ -2230,7 +2232,7 @@ Can't pass arguments to remote MIPS board; arguments ignored.");
init_wait_for_inferior ();
/* FIXME: Should we set inferior_pid here? */
/* FIXME: Should we set inferior_ptid here? */
proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
}
@ -3439,7 +3441,7 @@ mips_load (char *file, int from_tty)
if (exec_bfd)
write_pc (bfd_get_start_address (exec_bfd));
inferior_pid = 0; /* No process now */
inferior_ptid = null_ptid; /* No process now */
/* This is necessary because many things were based on the PC at the time that
we attached to the monitor, which is no longer valid now that we have loaded

View File

@ -51,7 +51,7 @@
extern int stop_soon_quietly; /* for wait_for_inferior */
static void mm_resume ();
static void mm_resume (ptid_t ptid, int step, enum target_signal sig)
static void mm_fetch_registers ();
static int fetch_register ();
static void mm_store_registers ();
@ -523,7 +523,7 @@ mm_detach (char *args, int from_tty)
** Tell the remote machine to resume. */
static void
mm_resume (int pid, int step, enum target_signal sig)
mm_resume (ptid_t ptid, int step, enum target_signal sig)
{
if (sig != TARGET_SIGNAL_0)
warning ("Can't send signals to a remote MiniMon system.");
@ -547,8 +547,8 @@ mm_resume (int pid, int step, enum target_signal sig)
** Wait until the remote machine stops, then return,
storing status in STATUS just as `wait' would. */
static int
mm_wait (struct target_waitstatus *status)
static ptid_t
mm_wait (ptid_t ptid, struct target_waitstatus *status)
{
int i, result;
int old_timeout = timeout;
@ -692,7 +692,7 @@ halted:
timeout = old_timeout; /* Restore original timeout value */
immediate_quit = old_immediate_quit;
return 0;
return inferior_ptid;
}
/******************************************************* REMOTE_FETCH_REGISTERS

Some files were not shown because too many files have changed in this diff Show More