]> granicus.if.org Git - strace/commitdiff
2008-08-19 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Wed, 20 Aug 2008 01:59:40 +0000 (01:59 +0000)
committerRoland McGrath <roland@redhat.com>
Wed, 20 Aug 2008 01:59:40 +0000 (01:59 +0000)
* signal.c (sys_sigaction, sys_rt_sigaction): Don't omit the rest of
the struct after sa_handler is a known constant.  Some sa_flags bits
have meaning even for SIG_IGN/SIG_DFL.

signal.c

index 25db0a0ec5ce61ff7f4824b2ecc177835879d079..ed413adf6a576912f594798dc0b8e72a8bb91665 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -1120,23 +1120,20 @@ struct tcb *tcp;
        else if (umove(tcp, addr, &sa) < 0)
                tprintf("{...}");
        else {
-               switch ((long) sa.SA_HANDLER) {
-               case (long) SIG_ERR:
-                       tprintf("{SIG_ERR}");
-                       break;
-               case (long) SIG_DFL:
-                       tprintf("{SIG_DFL}");
-                       break;
-               case (long) SIG_IGN:
+               if (sa.SA_HANDLER == SIG_ERR)
+                       tprintf("{SIG_ERR, ");
+               else if (sa.SA_HANDLER == SIG_DFL)
+                       tprintf("{SIG_DFL, ");
+               else if (sa.SA_HANDLER == SIG_DFL) {
 #ifndef USE_PROCFS
                        if (tcp->u_arg[0] == SIGTRAP) {
                                tcp->flags |= TCB_SIGTRAPPED;
                                kill(tcp->pid, SIGSTOP);
                        }
 #endif /* !USE_PROCFS */
-                       tprintf("{SIG_IGN}");
-                       break;
-               default:
+                       tprintf("{SIG_IGN");
+               }
+               else {
 #ifndef USE_PROCFS
                        if (tcp->u_arg[0] == SIGTRAP) {
                                tcp->flags |= TCB_SIGTRAPPED;
@@ -1865,7 +1862,7 @@ struct new_sigaction
 };
 
 
-       int
+int
 sys_rt_sigaction(tcp)
        struct tcb *tcp;
 {
@@ -1886,38 +1883,33 @@ sys_rt_sigaction(tcp)
        else if (umove(tcp, addr, &sa) < 0)
                tprintf("{...}");
        else {
-               switch ((long) sa.__sigaction_handler.__sa_handler) {
-                       case (long) SIG_ERR:
-                               tprintf("{SIG_ERR}");
-                               break;
-                       case (long) SIG_DFL:
-                               tprintf("{SIG_DFL}");
-                               break;
-                       case (long) SIG_IGN:
-                               tprintf("{SIG_IGN}");
-                               break;
-                       default:
-                               tprintf("{%#lx, ",
-                                               (long) sa.__sigaction_handler.__sa_handler);
-                               sigemptyset(&sigset);
+               if (sa.__sigaction_handler.__sa_handler == SIG_ERR)
+                       tprintf("{SIG_ERR, ");
+               else if (sa.__sigaction_handler.__sa_handler == SIG_DFL)
+                       tprintf("{SIG_DFL, ");
+               else if (sa.__sigaction_handler.__sa_handler == SIG_DFL)
+                       tprintf("{SIG_IGN, ");
+               else
+                       tprintf("{%#lx, ",
+                               (long) sa.__sigaction_handler.__sa_handler);
+               sigemptyset(&sigset);
 #ifdef LINUXSPARC
-                               if (tcp->u_arg[4] <= sizeof(sigset))
-                                       memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
+               if (tcp->u_arg[4] <= sizeof(sigset))
+                       memcpy(&sigset, &sa.sa_mask, tcp->u_arg[4]);
 #else
-                               if (tcp->u_arg[3] <= sizeof(sigset))
-                                       memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
+               if (tcp->u_arg[3] <= sizeof(sigset))
+                       memcpy(&sigset, &sa.sa_mask, tcp->u_arg[3]);
 #endif
-                               else
-                                       memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
-                               printsigmask(&sigset, 1);
-                               tprintf(", ");
-                               printflags(sigact_flags, sa.sa_flags, "SA_???");
+               else
+                       memcpy(&sigset, &sa.sa_mask, sizeof(sigset));
+               printsigmask(&sigset, 1);
+               tprintf(", ");
+               printflags(sigact_flags, sa.sa_flags, "SA_???");
 #ifdef SA_RESTORER
-                               if (sa.sa_flags & SA_RESTORER)
-                                       tprintf(", %p", sa.sa_restorer);
+               if (sa.sa_flags & SA_RESTORER)
+                       tprintf(", %p", sa.sa_restorer);
 #endif
-                               tprintf("}");
-               }
+               tprintf("}");
        }
        if (entering(tcp))
                tprintf(", ");