if (ptrace(PTRACE_TRACEME, 0L, 0L, 0L) < 0)
perror_msg_and_die("%s: PTRACE_TRACEME doesn't work",
__func__);
- kill(pid, SIGSTOP);
+ kill_save_errno(pid, SIGSTOP);
if (fork() < 0)
perror_msg_and_die("fork");
_exit(0);
if (tracee_pid <= 0) {
if (errno == EINTR)
continue;
- else if (errno == ECHILD)
+ if (errno == ECHILD)
break;
kill_save_errno(pid, SIGKILL);
perror_msg_and_die("%s: unexpected wait result %d",
if (!WIFSTOPPED(status)) {
if (tracee_pid != pid)
kill_save_errno(tracee_pid, SIGKILL);
- kill(pid, SIGKILL);
+ kill_save_errno(pid, SIGKILL);
error_msg_and_die("%s: unexpected wait status %x",
__func__, status);
}
return 0;
default:
errno = wait_errno;
- perror("strace: wait");
+ perror_msg("wait");
return -1;
}
}
if (op == PTRACE_LISTEN)
msg = "LISTEN";
#endif
- perror_msg("ptrace(PTRACE_%s,1,%d)", msg, sig);
+ perror_msg("ptrace(PTRACE_%s,pid:%d,1,sig:%d)", msg, tcp->pid, sig);
return -1;
}
if (errno) {
/* But if not started, we had a bogus address. */
if (addr != 0 && errno != EIO && errno != ESRCH)
- perror("ptrace: umoven");
+ perror_msg("umoven: PTRACE_PEEKDATA pid:%d @0x%lx", pid, addr);
return -1;
}
started = 1;
return 0;
}
if (addr != 0 && errno != EIO && errno != ESRCH)
- perror("ptrace: umoven");
+ perror_msg("umoven: PTRACE_PEEKDATA pid:%d @0x%lx", pid, addr);
return -1;
}
started = 1;
u.val = ptrace(PTRACE_PEEKDATA, pid, (char *)addr, 0);
if (errno) {
if (addr != 0 && errno != EIO && errno != ESRCH)
- perror("umovestr");
+ perror_msg("umovestr: PTRACE_PEEKDATA pid:%d @0x%lx", pid, addr);
return -1;
}
started = 1;
return 0;
}
if (addr != 0 && errno != EIO && errno != ESRCH)
- perror("umovestr");
+ perror_msg("umovestr: PTRACE_PEEKDATA pid:%d @0x%lx", pid, addr);
return -1;
}
started = 1;
val = do_ptrace(PTRACE_PEEKUSER, tcp, (char *) off, 0);
if (val == -1 && errno) {
if (errno != ESRCH) {
- char buf[60];
- sprintf(buf, "upeek: ptrace(PTRACE_PEEKUSER,%d,%lu,0)", tcp->pid, off);
- perror(buf);
+ perror_msg("upeek: PTRACE_PEEKUSER pid:%d @0x%lx)", tcp->pid, off);
}
return -1;
}