Lines Matching refs:pid
253 Bool waitstopped (pid_t pid, int signal_expected, const char *msg) in waitstopped() argument
263 p = waitpid(pid, &status, __WALL); in waitstopped()
264 DEBUG(1, "after waitpid pid %d p %d status 0x%x %s\n", pid, p, in waitstopped()
266 if (p != pid) { in waitstopped()
268 msg, pid, p, status, status_image (status)); in waitstopped()
309 res = ptrace (PTRACE_GETSIGINFO, pid, NULL, newsiginfo); in waitstopped()
317 res = ptrace (PTRACE_CONT, pid, NULL, 0); in waitstopped()
320 res = ptrace (PTRACE_CONT, pid, NULL, signal_received); in waitstopped()
335 Bool stop (pid_t pid, const char *msg) in stop() argument
339 DEBUG(1, "%s SIGSTOP pid %d\n", msg, pid); in stop()
340 res = kill (pid, SIGSTOP); in stop()
342 ERROR(errno, "%s SIGSTOP pid %d %ld\n", msg, pid, res); in stop()
346 return waitstopped (pid, SIGSTOP, msg); in stop()
354 Bool attach (pid_t pid, const char *msg) in attach() argument
364 DEBUG(1, "%s PTRACE_ATTACH pid %d\n", msg, pid); in attach()
365 res = ptrace (PTRACE_ATTACH, pid, NULL, NULL); in attach()
368 ERROR(errno, "%s PTRACE_ATTACH pid %d %ld\n", msg, pid, res); in attach()
377 return waitstopped(pid, SIGSTOP, msg); in attach()
384 Bool acquire_and_suspend_threads (pid_t pid) in acquire_and_suspend_threads() argument
418 rw = ptrace_read_memory(pid, vgt+off_status, in acquire_and_suspend_threads()
426 rw = ptrace_read_memory(pid, vgt+off_lwpid, in acquire_and_suspend_threads()
454 if (vgdb_threads[i].lwpid == pid) { in acquire_and_suspend_threads()
476 void detach_from_all_threads (pid_t pid) in detach_from_all_threads() argument
491 if (vgdb_threads[i].lwpid == pid) { in detach_from_all_threads()
511 if (!pid_found && pid) { in detach_from_all_threads()
514 DEBUG(1, "no thread live => PTRACE_DETACH pid %d\n", pid); in detach_from_all_threads()
515 res = ptrace (PTRACE_DETACH, pid, NULL, NULL); in detach_from_all_threads()
517 ERROR(errno, "PTRACE_DETACH pid %d res %ld\n", pid, res); in detach_from_all_threads()
552 Bool getregs (pid_t pid, void *regs, long regs_bsz) in getregs() argument
572 res = ptrace (PTRACE_GETREGSET, pid, NT_PRSTATUS, &iovec); in getregs()
607 res = ptrace (PTRACE_GETREGS, pid, NULL, regs); in getregs()
650 *(long *)(pregs+offset) = ptrace(PTRACE_PEEKUSER, pid, offset, NULL); in getregs()
668 Bool setregs (pid_t pid, void *regs, long regs_bsz) in setregs() argument
687 res = ptrace (PTRACE_SETREGSET, pid, NT_PRSTATUS, &iovec); in setregs()
705 res = ptrace (PTRACE_SETREGS, pid, NULL, regs); in setregs()
727 res = ptrace(PTRACE_POKEUSER, pid, offset, *(long*)(pregs+offset)); in setregs()
743 void restore_and_detach (pid_t pid) in restore_and_detach() argument
748 pid, pid_of_save_regs); in restore_and_detach()
790 detach_from_all_threads(pid); in restore_and_detach()
793 Bool invoker_invoke_gdbserver (pid_t pid) in invoker_invoke_gdbserver() argument
822 DEBUG(1, "attach to 'main' pid %d\n", pid); in invoker_invoke_gdbserver()
823 if (!attach(pid, "attach main pid")) { in invoker_invoke_gdbserver()
824 ERROR(0, "error attach main pid %d\n", pid); in invoker_invoke_gdbserver()
830 if (!acquire_and_suspend_threads(pid)) { in invoker_invoke_gdbserver()
831 detach_from_all_threads(pid); in invoker_invoke_gdbserver()
833 if (kill(pid, 0) != 0) in invoker_invoke_gdbserver()
835 pid); in invoker_invoke_gdbserver()
839 if (!getregs(pid, &user_mod.regs, sizeof(user_mod.regs))) { in invoker_invoke_gdbserver()
840 detach_from_all_threads(pid); in invoker_invoke_gdbserver()
892 rw = ptrace_write_memory(pid, sp, in invoker_invoke_gdbserver()
897 detach_from_all_threads(pid); in invoker_invoke_gdbserver()
905 rw = ptrace_write_memory(pid, sp, in invoker_invoke_gdbserver()
910 detach_from_all_threads(pid); in invoker_invoke_gdbserver()
982 rw = ptrace_write_memory(pid, sp, in invoker_invoke_gdbserver()
987 detach_from_all_threads(pid); in invoker_invoke_gdbserver()
1012 rw = ptrace_read_memory(pid, shared64->invoke_gdbserver, in invoker_invoke_gdbserver()
1017 detach_from_all_threads(pid); in invoker_invoke_gdbserver()
1020 rw = ptrace_read_memory(pid, shared64->invoke_gdbserver+8, in invoker_invoke_gdbserver()
1025 detach_from_all_threads(pid); in invoker_invoke_gdbserver()
1082 if (!setregs(pid, &user_mod.regs, sizeof(user_mod.regs))) { in invoker_invoke_gdbserver()
1083 detach_from_all_threads(pid); in invoker_invoke_gdbserver()
1089 pid_of_save_regs = pid; in invoker_invoke_gdbserver()
1101 res = ptrace (PTRACE_CONT, pid, NULL, NULL); in invoker_invoke_gdbserver()
1104 restore_and_detach(pid); in invoker_invoke_gdbserver()
1109 stopped = waitstopped (pid, SIGSTOP, in invoker_invoke_gdbserver()
1114 restore_and_detach(pid); in invoker_invoke_gdbserver()