Use perror_msg instead of perror
* signal.c (sys_sigreturn): Use perror_msg instead of perror.
* strace.c (tprintf, tprints, detach, startup_attach): Likewise.
* syscall.c (get_scno): Likewise.
* util.c (umoven, umovestr): Likewise.
diff --git a/signal.c b/signal.c
index 1441de1..efe335c 100644
--- a/signal.c
+++ b/signal.c
@@ -990,12 +990,12 @@
m_siginfo_t si;
sigset_t sigm;
if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
- perror("sigreturn: PTRACE_GETREGS");
+ perror_msg("%s", "sigreturn: PTRACE_GETREGS");
return 0;
}
i1 = regs.u_regs[U_REG_O1];
if (umove(tcp, i1, &si) < 0) {
- perror("sigreturn: umove");
+ perror_msg("%s", "sigreturn: umove");
return 0;
}
long_to_sigset(si.si_mask, &sigm);
@@ -1024,7 +1024,7 @@
m_siginfo_t si;
sigset_t sigm;
if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
- perror("sigreturn: PTRACE_GETREGS");
+ perror_msg("%s", "sigreturn: PTRACE_GETREGS");
return 0;
}
sp = regs.regs[29];
@@ -1039,7 +1039,7 @@
long regs[PT_MAX+1];
sigset_t sigm;
if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (long)regs) < 0) {
- perror("sigreturn: PTRACE_GETREGS");
+ perror_msg("%s", "sigreturn: PTRACE_GETREGS");
return 0;
}
if (umove(tcp, regs[PT_USP], &sc) < 0)
diff --git a/strace.c b/strace.c
index 8fbd8ce..1331e38 100644
--- a/strace.c
+++ b/strace.c
@@ -515,8 +515,7 @@
int n = strace_vfprintf(current_tcp->outf, fmt, args);
if (n < 0) {
if (current_tcp->outf != stderr)
- perror(outfname == NULL
- ? "<writing to pipe>" : outfname);
+ perror_msg("%s", outfname);
} else
current_tcp->curcol += n;
}
@@ -533,7 +532,7 @@
return;
}
if (current_tcp->outf != stderr)
- perror(!outfname ? "<writing to pipe>" : outfname);
+ perror_msg("%s", outfname);
}
}
@@ -750,15 +749,15 @@
}
else if (errno != ESRCH) {
/* Shouldn't happen. */
- perror("detach: ptrace(PTRACE_DETACH, ...)");
+ perror_msg("%s", "detach: ptrace(PTRACE_DETACH, ...)");
}
else if (my_tkill(tcp->pid, 0) < 0) {
if (errno != ESRCH)
- perror("detach: checking sanity");
+ perror_msg("%s", "detach: checking sanity");
}
else if (!sigstop_expected && my_tkill(tcp->pid, SIGSTOP) < 0) {
if (errno != ESRCH)
- perror("detach: stopping child");
+ perror_msg("%s", "detach: stopping child");
}
else
sigstop_expected = 1;
@@ -771,21 +770,21 @@
if (errno == ECHILD) /* Already gone. */
break;
if (errno != EINVAL) {
- perror("detach: waiting");
+ perror_msg("%s", "detach: waiting");
break;
}
#endif /* __WALL */
/* No __WALL here. */
if (waitpid(tcp->pid, &status, 0) < 0) {
if (errno != ECHILD) {
- perror("detach: waiting");
+ perror_msg("%s", "detach: waiting");
break;
}
#ifdef __WCLONE
/* If no processes, try clones. */
if (waitpid(tcp->pid, &status, __WCLONE) < 0) {
if (errno != ECHILD)
- perror("detach: waiting");
+ perror_msg("%s", "detach: waiting");
break;
}
#endif /* __WCLONE */
@@ -934,7 +933,7 @@
}
ntid -= nerr;
if (ntid == 0) {
- perror("attach: ptrace(PTRACE_ATTACH, ...)");
+ perror_msg("%s", "attach: ptrace(PTRACE_ATTACH, ...)");
droptcb(tcp);
continue;
}
@@ -955,7 +954,7 @@
} /* if (opendir worked) */
} /* if (-f) */
if (ptrace_attach_or_seize(tcp->pid) < 0) {
- perror("attach: ptrace(PTRACE_ATTACH, ...)");
+ perror_msg("%s", "attach: ptrace(PTRACE_ATTACH, ...)");
droptcb(tcp);
continue;
}
diff --git a/syscall.c b/syscall.c
index 52d742f..cda017c 100644
--- a/syscall.c
+++ b/syscall.c
@@ -721,7 +721,7 @@
errno = 0;
opcode = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *)(pc-sizeof(long)), 0);
if (errno) {
- perror("peektext(pc-oneword)");
+ perror_msg("%s", "peektext(pc-oneword)");
return -1;
}
diff --git a/util.c b/util.c
index 9ca49b2..8254677 100644
--- a/util.c
+++ b/util.c
@@ -789,9 +789,10 @@
if (r < 0) {
if (errno == ENOSYS)
process_vm_readv_not_supported = 1;
- else if (errno != EINVAL && errno != ESRCH) /* EINVAL is seen if process is gone */
- /* strange... */
- perror("process_vm_readv");
+ else if (errno != EINVAL && errno != ESRCH)
+ /* EINVAL or ESRCH could be seen if process is gone,
+ * all the rest is strange and should be reported. */
+ perror_msg("%s", "process_vm_readv");
goto vm_readv_didnt_work;
}
return r;
@@ -899,9 +900,11 @@
if (r < 0) {
if (errno == ENOSYS)
process_vm_readv_not_supported = 1;
- else if (errno != EINVAL && errno != ESRCH) /* EINVAL is seen if process is gone */
- /* strange... */
- perror("process_vm_readv");
+ else if (errno != EINVAL && errno != ESRCH)
+ /* EINVAL or ESRCH could be seen
+ * if process is gone, all the rest
+ * is strange and should be reported. */
+ perror_msg("%s", "process_vm_readv");
goto vm_readv_didnt_work;
}
if (memchr(local[0].iov_base, '\0', r))