Decode siginfo_t more clearly for si_code SI_TIMER.

The 'pid' is actually a POSIX timer id, and the 'uid' is actually the overrun.

Also factor out the si_value dumping so it's the same for every si_code.

Signed-off-by: Elliott Hughes <[email protected]>
diff --git a/signal.c b/signal.c
index ce8ec0a..69fea37 100644
--- a/signal.c
+++ b/signal.c
@@ -499,6 +499,17 @@ static const struct xlat sigbus_codes[] = {
        XLAT_END
 };
 
+static void
+printsigval(siginfo_t *sip, int verbose)
+{
+       if (!verbose)
+               tprints(", ...");
+       else
+               tprintf(", si_value={int=%u, ptr=%#lx}",
+                       sip->si_int,
+                       (unsigned long) sip->si_ptr);
+}
+
 void
 printsiginfo(siginfo_t *sip, int verbose)
 {
@@ -561,32 +572,35 @@ printsiginfo(siginfo_t *sip, int verbose)
                }
 #ifdef SI_FROMUSER
                if (SI_FROMUSER(sip)) {
-                       tprintf(", si_pid=%lu, si_uid=%lu",
-                               (unsigned long) sip->si_pid,
-                               (unsigned long) sip->si_uid);
                        switch (sip->si_code) {
 #ifdef SI_USER
                        case SI_USER:
+                               tprintf(", si_pid=%lu, si_uid=%lu",
+                                       (unsigned long) sip->si_pid,
+                                       (unsigned long) sip->si_uid);
                                break;
 #endif
 #ifdef SI_TKILL
                        case SI_TKILL:
+                               tprintf(", si_pid=%lu, si_uid=%lu",
+                                       (unsigned long) sip->si_pid,
+                                       (unsigned long) sip->si_uid);
                                break;
 #endif
 #ifdef SI_TIMER
                        case SI_TIMER:
-                               tprintf(", si_value=%d", sip->si_int);
+                               tprintf(", si_timerid=%#x, si_overrun=%d",
+                                       sip->si_timerid, sip->si_overrun);
+                               printsigval(sip, verbose);
                                break;
 #endif
                        default:
+                       tprintf(", si_pid=%lu, si_uid=%lu",
+                               (unsigned long) sip->si_pid,
+                               (unsigned long) sip->si_uid);
                                if (!sip->si_ptr)
                                        break;
-                               if (!verbose)
-                                       tprints(", ...");
-                               else
-                                       tprintf(", si_value={int=%u, ptr=%#lx}",
-                                               sip->si_int,
-                                               (unsigned long) sip->si_ptr);
+                               printsigval(sip, verbose);
                                break;
                        }
                }
@@ -628,13 +642,7 @@ printsiginfo(siginfo_t *sip, int verbose)
                                                (unsigned long) sip->si_uid);
                                if (!sip->si_ptr)
                                        break;
-                               if (!verbose)
-                                       tprints(", ...");
-                               else {
-                                       tprintf(", si_value={int=%u, ptr=%#lx}",
-                                               sip->si_int,
-                                               (unsigned long) sip->si_ptr);
-                               }
+                               printsigval(sip, verbose);
 
                        }
                }
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to