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>
This commit is contained in:
parent
be99497d39
commit
d4d3edefe7
1
defs.h
1
defs.h
@ -637,6 +637,7 @@ extern void print_timespec(struct tcb *, long);
|
||||
extern void sprint_timespec(char *, struct tcb *, long);
|
||||
#ifdef HAVE_SIGINFO_T
|
||||
extern void printsiginfo(siginfo_t *, int);
|
||||
extern void printsiginfo_at(struct tcb *tcp, long addr);
|
||||
#endif
|
||||
extern void printfd(struct tcb *, int);
|
||||
extern void printsock(struct tcb *, long, int);
|
||||
|
31
process.c
31
process.c
@ -1126,22 +1126,13 @@ static const struct xlat waitid_types[] = {
|
||||
int
|
||||
sys_waitid(struct tcb *tcp)
|
||||
{
|
||||
siginfo_t si;
|
||||
|
||||
if (entering(tcp)) {
|
||||
printxval(waitid_types, tcp->u_arg[0], "P_???");
|
||||
tprintf(", %ld, ", tcp->u_arg[1]);
|
||||
}
|
||||
else {
|
||||
/* siginfo */
|
||||
if (!tcp->u_arg[2])
|
||||
tprints("NULL");
|
||||
else if (syserror(tcp))
|
||||
tprintf("%#lx", tcp->u_arg[2]);
|
||||
else if (umove(tcp, tcp->u_arg[2], &si) < 0)
|
||||
tprints("{???}");
|
||||
else
|
||||
printsiginfo(&si, verbose(tcp));
|
||||
printsiginfo_at(tcp, tcp->u_arg[2]);
|
||||
/* options */
|
||||
tprints(", ");
|
||||
printflags(wait4_options, tcp->u_arg[3], "W???");
|
||||
@ -2306,15 +2297,7 @@ sys_ptrace(struct tcb *tcp)
|
||||
#endif
|
||||
#ifdef PTRACE_SETSIGINFO
|
||||
case PTRACE_SETSIGINFO: {
|
||||
siginfo_t si;
|
||||
if (!tcp->u_arg[3])
|
||||
tprints("NULL");
|
||||
else if (syserror(tcp))
|
||||
tprintf("%#lx", tcp->u_arg[3]);
|
||||
else if (umove(tcp, tcp->u_arg[3], &si) < 0)
|
||||
tprints("{???}");
|
||||
else
|
||||
printsiginfo(&si, verbose(tcp));
|
||||
printsiginfo_at(tcp, tcp->u_arg[3]);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -2347,15 +2330,7 @@ sys_ptrace(struct tcb *tcp)
|
||||
#endif
|
||||
#ifdef PTRACE_GETSIGINFO
|
||||
case PTRACE_GETSIGINFO: {
|
||||
siginfo_t si;
|
||||
if (!tcp->u_arg[3])
|
||||
tprints("NULL");
|
||||
else if (syserror(tcp))
|
||||
tprintf("%#lx", tcp->u_arg[3]);
|
||||
else if (umove(tcp, tcp->u_arg[3], &si) < 0)
|
||||
tprints("{???}");
|
||||
else
|
||||
printsiginfo(&si, verbose(tcp));
|
||||
printsiginfo_at(tcp, tcp->u_arg[3]);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
43
signal.c
43
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);
|
||||
@ -1230,7 +1248,6 @@ sys_rt_sigaction(struct tcb *tcp)
|
||||
sa.sa_mask[0] = sa32.sa_mask[0] + ((long)(sa32.sa_mask[1]) << 32);
|
||||
}
|
||||
} 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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user