summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-02-13 16:31:32 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-02-13 16:31:32 +0100
commitd4d3edefe74787a194a2472d99a673f6d4a2721a (patch)
tree354fb9072c75fca1ac7ae8081a7351be401c4071 /signal.c
parentbe99497d39a0ccc59cde4d21bbd307767ab3860c (diff)
downloadstrace-d4d3edefe74787a194a2472d99a673f6d4a2721a.tar.gz
strace-d4d3edefe74787a194a2472d99a673f6d4a2721a.tar.bz2
strace-d4d3edefe74787a194a2472d99a673f6d4a2721a.tar.xz
Factor out code to check addr, fetch and print siginfo
* defs.h: Declare new function printsiginfo_at(tcp, addr). * process.c (sys_waitid): Use printsiginfo_at(). (sys_ptrace): Likewise. * signal.c: (printsiginfo_at): Implement this new function. (sys_rt_sigsuspend): Use printsiginfo_at(). (sys_rt_sigtimedwait): Likewise. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/signal.c b/signal.c
index 5e862ad..55ff3ed 100644
--- a/signal.c
+++ b/signal.c
@@ -671,6 +671,25 @@ printsiginfo(siginfo_t *sip, int verbose)
tprints("}");
}
+void
+printsiginfo_at(struct tcb *tcp, long addr)
+{
+ siginfo_t si;
+ if (!addr) {
+ tprints("NULL");
+ return;
+ }
+ if (syserror(tcp)) {
+ tprintf("%#lx", addr);
+ return;
+ }
+ if (umove(tcp, addr, &si) < 0) {
+ tprints("{???}");
+ return;
+ }
+ printsiginfo(&si, verbose(tcp));
+}
+
int
sys_sigsetmask(struct tcb *tcp)
{
@@ -1209,8 +1228,7 @@ sys_rt_sigaction(struct tcb *tcp)
tprintf("%#lx", addr);
goto after_sa;
}
-#if SUPPORTED_PERSONALITIES > 1
-#if SIZEOF_LONG > 4
+#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
if (current_wordsize != sizeof(sa.sa_flags) && current_wordsize == 4) {
struct new_sigaction32 sa32;
r = umove(tcp, addr, &sa32);
@@ -1231,7 +1249,6 @@ sys_rt_sigaction(struct tcb *tcp)
}
} else
#endif
-#endif
{
r = umove(tcp, addr, &sa);
}
@@ -1326,14 +1343,9 @@ sys_rt_sigsuspend(struct tcb *tcp)
static void
print_sigqueueinfo(struct tcb *tcp, int sig, unsigned long uinfo)
{
- siginfo_t si;
-
printsignal(sig);
tprints(", ");
- if (umove(tcp, uinfo, &si) < 0)
- tprintf("%#lx", uinfo);
- else
- printsiginfo(&si, verbose(tcp));
+ printsiginfo_at(tcp, uinfo);
}
int
@@ -1375,17 +1387,8 @@ int sys_rt_sigtimedwait(struct tcb *tcp)
}
else if (tcp->u_arg[1] != 0) {
/* syscall exit, and u_arg[1] wasn't NULL */
- if (syserror(tcp))
- tprintf("%#lx, ", tcp->u_arg[1]);
- else {
- siginfo_t si;
- if (umove(tcp, tcp->u_arg[1], &si) < 0)
- tprintf("%#lx, ", tcp->u_arg[1]);
- else {
- printsiginfo(&si, verbose(tcp));
- tprints(", ");
- }
- }
+ printsiginfo_at(tcp, tcp->u_arg[1]);
+ tprints(", ");
}
else {
/* syscall exit, and u_arg[1] was NULL */