Home | History | Annotate | Download | only in strace

Lines Matching defs:pid

62       while we later wait on a that specific TID.  PID process waits become
111 * attaches to grandparent similarly to strace -p PID.
202 -p pid... / [-D] [-E var=val]... [-u username] PROG [ARGS]\n\
204 -p pid... / [-D] [-E var=val]... [-u username] PROG [ARGS]\n\
232 -p pid -- trace process with process id PID, may be repeated\n\
344 ptrace_attach_or_seize(int pid)
348 return ptrace(PTRACE_ATTACH, pid, 0L, 0L);
349 r = ptrace(PTRACE_SEIZE, pid, 0L, (unsigned long) ptrace_setoptions);
352 r = ptrace(PTRACE_INTERRUPT, pid, 0L, 0L);
356 # define ptrace_attach_or_seize(pid) ptrace(PTRACE_ATTACH, (pid), 0, 0)
373 ptrace(op, tcp->pid, (void *) 0, (long) sig);
403 perror_msg("ptrace(PTRACE_%s,pid:%d,sig:%d)", msg, tcp->pid, sig);
429 static void kill_save_errno(pid_t pid, int sig)
433 (void) kill(pid, sig);
496 * does not export its child's pid.
502 int pid;
511 pid = vfork();
512 if (pid < 0)
515 if (pid == 0) {
528 popen_pid = pid;
613 pid);
615 tprintf("[pid %5u] ", tcp->pid);
665 sprintf(name, "%.512s.%u", outfname, tcp->pid);
690 alloctcb(int pid)
700 if (!tcp->pid) {
702 tcp->pid = pid;
714 fprintf(stderr, "new tcb for pid %d, active tcbs:%d\n", tcp->pid, nprocs);
724 if (tcp->pid == 0)
735 fprintf(stderr, "dropped tcb for pid %d, %d remain\n", tcp->pid, nprocs);
788 error = ptrace(PTRACE_DETACH, tcp->pid, 0, 0);
795 perror_msg("detach: ptrace(PTRACE_DETACH,%u)", tcp->pid);
799 if (my_tkill(tcp->pid, 0) < 0) {
802 perror_msg("detach: tkill(%u,0)", tcp->pid);
814 error = ptrace(PTRACE_INTERRUPT, tcp->pid, 0, 0);
818 perror_msg("detach: ptrace(PTRACE_INTERRUPT,%u)", tcp->pid);
821 error = my_tkill(tcp->pid, SIGSTOP);
825 perror_msg("detach: tkill(%u,SIGSTOP)", tcp->pid);
838 if (waitpid(tcp->pid, &status, __WALL) < 0) {
843 * ^^^ WRONG! We expect this PID to exist,
846 perror_msg("detach: waitpid(%u)", tcp->pid);
854 * Consider "strace -p PID" being ^C-ed:
855 * we want merely to detach from PID.
918 fprintf(stderr, "Process %u detached\n", tcp->pid);
928 * We accept -p PID,PID; -p "`pidof PROG`"; -p "`pgrep PROG`".
931 int pid;
936 pid = string_to_uint(opt);
937 if (pid <= 0) {
940 if (pid == strace_tracer_pid) {
944 alloctcb(pid);
967 pid_t pid = fork();
968 if (pid < 0) {
971 if (pid) { /* parent */
982 /* We will be the tracer process. Remember our new pid: */
989 if (!tcp->pid)
1000 sprintf(procdir, "/proc/%d/task", tcp->pid);
1020 fprintf(stderr, "attach to pid %d failed\n", tid);
1024 fprintf(stderr, "attach to pid %d succeeded\n", tid);
1026 if (tid != tcp->pid)
1048 tcp->pid, ntid);
1051 /* -p PID, we failed to attach to PID itself
1053 * Drop PID's tcp.
1060 if (ptrace_attach_or_seize(tcp->pid) < 0) {
1068 fprintf(stderr, "attach to pid %d (main) succeeded\n", tcp->pid);
1081 tcp->pid);
1163 int pid;
1243 pid = fork();
1244 if (pid < 0) {
1247 if ((pid != 0 && daemonized_tracer)
1248 || (pid == 0 && !daemonized_tracer)
1260 strace_child = pid;
1267 pid, &status, WSTOPPED) < 0) {
1273 kill_save_errno(pid, SIGKILL);
1282 if (ptrace_attach_or_seize(pid)) {
1283 kill_save_errno(pid, SIGKILL);
1284 perror_msg_and_die("Can't attach to %d", pid);
1287 kill(pid, SIGCONT);
1289 tcp = alloctcb(pid);
1297 /* With -D, we are *child* here, IOW: different pid. Fetch it: */
1300 pid = getppid();
1301 alloctcb(pid);
1332 int pid;
1340 pid = fork();
1341 if (pid < 0)
1344 if (pid == 0) {
1353 if (ptrace(PTRACE_SEIZE, pid, 0, 0) == 0) {
1359 kill(pid, SIGKILL);
1365 tracee_pid = waitpid(pid, &status, 0);
1605 /* Must have PROG [ARGS], or -p PID. Not both. */
1678 * We can't do the <outfname>.PID funny business
1738 * In interactive mode (if no -o OUTFILE, or -p PID is used),
1762 * -ff: no (every pid has its own file); or
1764 * -p PID1,PID2: yes (there are already more than one pid)
1770 pid2tcb(int pid)
1774 if (pid <= 0)
1779 if (tcp->pid == pid)
1800 if (!tcp->pid)
1804 "cleanup: looking at pid %u\n", tcp->pid);
1805 if (tcp->pid == strace_child) {
1806 kill(tcp->pid, SIGCONT);
1807 kill(tcp->pid, fatal_sig);
1822 print_debug_info(const int pid, int status)
1865 fprintf(stderr, " [wait(0x%06x) = %u] %s%s\n", status, pid, buf, evbuf);
1869 maybe_allocate_tcb(const int pid, int status)
1872 if (detach_on_execve && pid == strace_child) {
1881 error_msg("Exit of unknown pid %u ignored", pid);
1886 struct tcb *tcp = alloctcb(pid);
1890 fprintf(stderr, "Process %d attached\n", pid);
1896 ptrace(PTRACE_CONT, pid, (char *) 0, 0);
1897 error_msg("Stop of unknown pid %u seen, PTRACE_CONTed it", pid);
1903 maybe_switch_tcbs(struct tcb *tcp, const int pid)
1909 if (ptrace(PTRACE_GETEVENTMSG, pid, NULL, (long) &old_pid) < 0)
1912 if (old_pid <= 0 || old_pid == pid)
1926 fprintf(execve_thread->outf, " <pid changed to %d ...>\n", pid);
1938 /* Switch to the thread, reusing leader's outfile and pid */
1940 tcp->pid = pid;
1943 tprintf("+++ superseded by execve in pid %lu +++\n", old_pid);
1952 print_signalled(struct tcb *tcp, const int pid, int status)
1954 if (pid == strace_child) {
1976 print_exited(struct tcb *tcp, const int pid, int status)
1978 if (pid == strace_child) {
2013 fprintf(stderr, "pid %d has TCB_STARTUP, initializing it\n",
2014 tcp->pid);
2020 fprintf(stderr, "setting opts 0x%x on pid %d\n",
2021 ptrace_setoptions, tcp->pid);
2022 if (ptrace(PTRACE_SETOPTIONS, tcp->pid, NULL, ptrace_setoptions) < 0) {
2035 int pid;
2070 pid = wait4(-1, &status, __WALL, (cflag ? &ru : NULL));
2075 if (pid < 0) {
2088 if (pid == popen_pid) {
2095 print_debug_info(pid, status);
2097 /* Look up 'pid' in our table. */
2098 tcp = pid2tcb(pid);
2101 tcp = maybe_allocate_tcb(pid, status);
2107 get_regs(pid);
2115 * Under Linux, execve changes pid to thread leader's pid,
2116 * and we see this changed pid on EVENT_EXEC and later,
2119 * and fix up pid in execve thread's tcb.
2126 * PTRACE_GETEVENTMSG returns old pid starting from Linux 3.0.
2130 tcp = maybe_switch_tcbs(tcp, pid);
2148 print_signalled(tcp, pid, status);
2154 print_exited(tcp, pid, status);
2164 error_msg("pid %u not stopped!", pid);
2208 fprintf(stderr, "ignored SIGSTOP on pid %d\n", tcp->pid);
2222 stopped = ptrace(PTRACE_GETSIGINFO, pid, 0, (long) &si) < 0;