]> granicus.if.org Git - strace/commitdiff
Use perror_msg instead of perror
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 17 Sep 2012 23:20:54 +0000 (23:20 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 28 Sep 2012 01:13:10 +0000 (01:13 +0000)
* 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.

signal.c
strace.c
syscall.c
util.c

index 1441de17f7e2f577b7559f297fcd5d2c85ac7d5c..efe335c291a6247c59c45589ca5897e757a3cecf 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -990,12 +990,12 @@ sys_sigreturn(struct tcb *tcp)
                m_siginfo_t si;
                sigset_t sigm;
                if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 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 @@ sys_sigreturn(struct tcb *tcp)
                m_siginfo_t si;
                sigset_t sigm;
                if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)&regs, 0) < 0) {
-                       perror("sigreturn: PTRACE_GETREGS");
+                       perror_msg("%s", "sigreturn: PTRACE_GETREGS");
                        return 0;
                }
                sp = regs.regs[29];
@@ -1039,7 +1039,7 @@ sys_sigreturn(struct tcb *tcp)
                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)
index 8fbd8cede350fa52997f35fa6a957dd0a4c6bdb8..1331e38bd784c0c9becebeb6f44a86847be09ef2 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -515,8 +515,7 @@ tprintf(const char *fmt, ...)
                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 @@ tprints(const char *str)
                        return;
                }
                if (current_tcp->outf != stderr)
-                       perror(!outfname ? "<writing to pipe>" : outfname);
+                       perror_msg("%s", outfname);
        }
 }
 
@@ -750,15 +749,15 @@ detach(struct tcb *tcp)
                }
                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 @@ detach(struct tcb *tcp)
                                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 @@ startup_attach(void)
                                }
                                ntid -= nerr;
                                if (ntid == 0) {
-                                       perror("attach: ptrace(PTRACE_ATTACH, ...)");
+                                       perror_msg("%s", "attach: ptrace(PTRACE_ATTACH, ...)");
                                        droptcb(tcp);
                                        continue;
                                }
@@ -955,7 +954,7 @@ startup_attach(void)
                        } /* 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;
                }
index 52d742f7e324f20bf82ee288a8c7fd13c0a5ebbf..cda017c584c2b251ad486078b7fd2c6efb1fdee1 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -721,7 +721,7 @@ get_scno(struct tcb *tcp)
                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 9ca49b27f68f3ed6d1ace9afde99115953d0b1e3..8254677f29732fc6a01a7d9e69e0e70ab760c8ed 100644 (file)
--- a/util.c
+++ b/util.c
@@ -789,9 +789,10 @@ umoven(struct tcb *tcp, long addr, int len, char *laddr)
                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 @@ umovestr(struct tcb *tcp, long addr, int len, char *laddr)
                        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))