]> granicus.if.org Git - strace/blob - signal.c
strace.c: rename set_sigaction to set_sighandler
[strace] / signal.c
1 /*
2  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5  * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6  * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7  *                     Linux for s390 port by D.J. Barrow
8  *                    <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
9  * Copyright (c) 2001-2017 The strace developers.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. The name of the author may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 #include "defs.h"
36 #include "nsig.h"
37 #include "xstring.h"
38
39 /* The libc headers do not define this constant since it should only be
40    used by the implementation.  So we define it here.  */
41 #ifndef SA_RESTORER
42 # ifdef ASM_SA_RESTORER
43 #  define SA_RESTORER ASM_SA_RESTORER
44 # endif
45 #endif
46
47 /*
48  * Some architectures define SA_RESTORER in their headers,
49  * but do not actually have sa_restorer.
50  *
51  * Some architectures, otherwise, do not define SA_RESTORER in their headers,
52  * but actually have sa_restorer.
53  */
54 #ifdef SA_RESTORER
55 # if defined HPPA || defined IA64
56 #  define HAVE_SA_RESTORER 0
57 # else
58 #  define HAVE_SA_RESTORER 1
59 # endif
60 #else /* !SA_RESTORER */
61 # if defined SPARC || defined SPARC64 || defined M68K
62 #  define HAVE_SA_RESTORER 1
63 # else
64 #  define HAVE_SA_RESTORER 0
65 # endif
66 #endif
67
68 #include "xlat/sa_handler_values.h"
69 #include "xlat/sigact_flags.h"
70 #include "xlat/sigprocmaskcmds.h"
71
72 /* Anonymous realtime signals. */
73 #ifndef ASM_SIGRTMIN
74 /* Linux kernel >= 3.18 defines SIGRTMIN to 32 on all architectures. */
75 # define ASM_SIGRTMIN 32
76 #endif
77 #ifndef ASM_SIGRTMAX
78 /* Under glibc 2.1, SIGRTMAX et al are functions, but __SIGRTMAX is a
79    constant.  This is what we want.  Otherwise, just use SIGRTMAX. */
80 # ifdef SIGRTMAX
81 #  ifndef __SIGRTMAX
82 #   define __SIGRTMAX SIGRTMAX
83 #  endif
84 # endif
85 # ifdef __SIGRTMAX
86 #  define ASM_SIGRTMAX __SIGRTMAX
87 # endif
88 #endif
89
90 /* Note on the size of sigset_t:
91  *
92  * In glibc, sigset_t is an array with space for 1024 bits (!),
93  * even though all arches supported by Linux have only 64 signals
94  * except MIPS, which has 128. IOW, it is 128 bytes long.
95  *
96  * In-kernel sigset_t is sized correctly (it is either 64 or 128 bit long).
97  * However, some old syscall return only 32 lower bits (one word).
98  * Example: sys_sigpending vs sys_rt_sigpending.
99  *
100  * Be aware of this fact when you try to
101  *     memcpy(&tcp->u_arg[1], &something, sizeof(sigset_t))
102  * - sizeof(sigset_t) is much bigger than you think,
103  * it may overflow tcp->u_arg[] array, and it may try to copy more data
104  * than is really available in <something>.
105  * Similarly,
106  *     umoven(tcp, addr, sizeof(sigset_t), &sigset)
107  * may be a bad idea: it'll try to read much more data than needed
108  * to fetch a sigset_t.
109  * Use NSIG_BYTES as a size instead.
110  */
111
112 static const char *
113 get_sa_handler_str(kernel_ulong_t handler)
114 {
115         return xlookup(sa_handler_values, handler);
116 }
117
118 static void
119 print_sa_handler(kernel_ulong_t handler)
120 {
121         const char *sa_handler_str = get_sa_handler_str(handler);
122
123         if (sa_handler_str)
124                 tprints(sa_handler_str);
125         else
126                 printaddr(handler);
127 }
128
129 const char *
130 signame(const int sig)
131 {
132         static char buf[sizeof("SIGRT_%u") + sizeof(int)*3];
133
134         if (sig >= 0) {
135                 const unsigned int s = sig;
136
137                 if (s < nsignals)
138                         return signalent[s];
139 #ifdef ASM_SIGRTMAX
140                 if (s >= ASM_SIGRTMIN && s <= (unsigned int) ASM_SIGRTMAX) {
141                         xsprintf(buf, "SIGRT_%u", s - ASM_SIGRTMIN);
142                         return buf;
143                 }
144 #endif
145         }
146         xsprintf(buf, "%d", sig);
147         return buf;
148 }
149
150 static unsigned int
151 popcount32(const uint32_t *a, unsigned int size)
152 {
153         unsigned int count = 0;
154
155         for (; size; ++a, --size) {
156                 uint32_t x = *a;
157
158 #ifdef HAVE___BUILTIN_POPCOUNT
159                 count += __builtin_popcount(x);
160 #else
161                 for (; x; ++count)
162                         x &= x - 1;
163 #endif
164         }
165
166         return count;
167 }
168
169 const char *
170 sprintsigmask_n(const char *prefix, const void *sig_mask, unsigned int bytes)
171 {
172         /*
173          * The maximum number of signal names to be printed
174          * is NSIG_BYTES * 8 * 2 / 3.
175          * Most of signal names have length 7,
176          * average length of signal names is less than 7.
177          * The length of prefix string does not exceed 16.
178          */
179         static char outstr[128 + 8 * (NSIG_BYTES * 8 * 2 / 3)];
180
181         char *s;
182         const uint32_t *mask;
183         uint32_t inverted_mask[NSIG_BYTES / 4];
184         unsigned int size;
185         int i;
186         char sep;
187
188         s = stpcpy(outstr, prefix);
189
190         mask = sig_mask;
191         /* length of signal mask in 4-byte words */
192         size = (bytes >= NSIG_BYTES) ? NSIG_BYTES / 4 : (bytes + 3) / 4;
193
194         /* check whether 2/3 or more bits are set */
195         if (popcount32(mask, size) >= size * (4 * 8) * 2 / 3) {
196                 /* show those signals that are NOT in the mask */
197                 unsigned int j;
198                 for (j = 0; j < size; ++j)
199                         inverted_mask[j] = ~mask[j];
200                 mask = inverted_mask;
201                 *s++ = '~';
202         }
203
204         sep = '[';
205         for (i = 0; (i = next_set_bit(mask, i, size * (4 * 8))) >= 0; ) {
206                 ++i;
207                 *s++ = sep;
208                 if ((unsigned) i < nsignals) {
209                         s = stpcpy(s, signalent[i] + 3);
210                 }
211 #ifdef ASM_SIGRTMAX
212                 else if (i >= ASM_SIGRTMIN && i <= ASM_SIGRTMAX) {
213                         s += xsnprintf(s, sizeof(outstr) - (s - outstr),
214                                        "RT_%u", i - ASM_SIGRTMIN);
215                 }
216 #endif
217                 else {
218                         s += xsnprintf(s, sizeof(outstr) - (s - outstr),
219                                        "%u", i);
220                 }
221                 sep = ' ';
222         }
223         if (sep == '[')
224                 *s++ = sep;
225         *s++ = ']';
226         *s = '\0';
227         return outstr;
228 }
229
230 #define sprintsigmask_val(prefix, mask) \
231         sprintsigmask_n((prefix), &(mask), sizeof(mask))
232
233 #define tprintsigmask_val(prefix, mask) \
234         tprints(sprintsigmask_n((prefix), &(mask), sizeof(mask)))
235
236 static const char *
237 sprint_old_sigmask_val(const char *const prefix, const unsigned long mask)
238 {
239 #if defined(current_wordsize) || !defined(WORDS_BIGENDIAN)
240         return sprintsigmask_n(prefix, &mask, current_wordsize);
241 #else /* !current_wordsize && WORDS_BIGENDIAN */
242         if (current_wordsize == sizeof(mask)) {
243                 return sprintsigmask_val(prefix, mask);
244         } else {
245                 uint32_t mask32 = mask;
246                 return sprintsigmask_val(prefix, mask32);
247         }
248 #endif
249 }
250
251 #define tprint_old_sigmask_val(prefix, mask) \
252         tprints(sprint_old_sigmask_val((prefix), (mask)))
253
254 void
255 printsignal(int nr)
256 {
257         tprints(signame(nr));
258 }
259
260 static void
261 print_sigset_addr_len_limit(struct tcb *const tcp, const kernel_ulong_t addr,
262                             const kernel_ulong_t len, const unsigned int min_len)
263 {
264         /*
265          * Here len is usually equal to NSIG_BYTES or current_wordsize.
266          * But we code this defensively:
267          */
268         if (len < min_len || len > NSIG_BYTES) {
269                 printaddr(addr);
270                 return;
271         }
272         int mask[NSIG_BYTES / sizeof(int)] = {};
273         if (umoven_or_printaddr(tcp, addr, len, mask))
274                 return;
275         tprints(sprintsigmask_n("", mask, len));
276 }
277
278 void
279 print_sigset_addr_len(struct tcb *const tcp, const kernel_ulong_t addr,
280                       const kernel_ulong_t len)
281 {
282         print_sigset_addr_len_limit(tcp, addr, len, current_wordsize);
283 }
284
285 void
286 print_sigset_addr(struct tcb *const tcp, const kernel_ulong_t addr)
287 {
288         print_sigset_addr_len_limit(tcp, addr, NSIG_BYTES, NSIG_BYTES);
289 }
290
291 SYS_FUNC(ssetmask)
292 {
293         if (entering(tcp)) {
294                 tprint_old_sigmask_val("", (unsigned) tcp->u_arg[0]);
295         } else if (!syserror(tcp)) {
296                 tcp->auxstr = sprint_old_sigmask_val("old mask ",
297                                                      (unsigned) tcp->u_rval);
298                 return RVAL_HEX | RVAL_STR;
299         }
300         return 0;
301 }
302
303 struct old_sigaction {
304         /* sa_handler may be a libc #define, need to use other name: */
305 #if defined MIPS
306         unsigned int sa_flags;
307         unsigned long sa_handler__;
308         unsigned long sa_mask;
309 #elif defined ALPHA
310         unsigned long sa_handler__;
311         unsigned long sa_mask;
312         unsigned int sa_flags;
313 #else
314         unsigned long sa_handler__;
315         unsigned long sa_mask;
316         unsigned long sa_flags;
317         unsigned long sa_restorer;
318 #endif
319 }
320 #ifdef ALPHA
321         ATTRIBUTE_PACKED
322 #endif
323 ;
324
325 static void
326 decode_old_sigaction(struct tcb *const tcp, const kernel_ulong_t addr)
327 {
328         struct old_sigaction sa;
329
330 #ifndef current_wordsize
331         if (current_wordsize < sizeof(sa.sa_handler__)) {
332                 struct old_sigaction32 {
333                         uint32_t sa_handler__;
334                         uint32_t sa_mask;
335                         uint32_t sa_flags;
336                         uint32_t sa_restorer;
337                 } sa32;
338
339                 if (umove_or_printaddr(tcp, addr, &sa32))
340                         return;
341
342                 memset(&sa, 0, sizeof(sa));
343                 sa.sa_handler__ = sa32.sa_handler__;
344                 sa.sa_flags = sa32.sa_flags;
345                 sa.sa_restorer = sa32.sa_restorer;
346                 sa.sa_mask = sa32.sa_mask;
347         } else
348 #endif
349         if (umove_or_printaddr(tcp, addr, &sa))
350                 return;
351
352         tprints("{sa_handler=");
353         print_sa_handler(sa.sa_handler__);
354         tprints(", sa_mask=");
355         tprint_old_sigmask_val("", sa.sa_mask);
356         tprints(", sa_flags=");
357         printflags(sigact_flags, sa.sa_flags, "SA_???");
358 #if !(defined ALPHA || defined MIPS)
359         if (sa.sa_flags & 0x04000000U) {
360                 tprints(", sa_restorer=");
361                 printaddr(sa.sa_restorer);
362         }
363 #endif
364         tprints("}");
365 }
366
367 SYS_FUNC(sigaction)
368 {
369         if (entering(tcp)) {
370                 int signo = tcp->u_arg[0];
371 #if defined SPARC || defined SPARC64
372                 if (signo < 0) {
373                         tprints("-");
374                         signo = -signo;
375                 }
376 #endif
377                 printsignal(signo);
378                 tprints(", ");
379                 decode_old_sigaction(tcp, tcp->u_arg[1]);
380                 tprints(", ");
381         } else
382                 decode_old_sigaction(tcp, tcp->u_arg[2]);
383         return 0;
384 }
385
386 SYS_FUNC(signal)
387 {
388         if (entering(tcp)) {
389                 printsignal(tcp->u_arg[0]);
390                 tprints(", ");
391                 print_sa_handler(tcp->u_arg[1]);
392                 return 0;
393         } else if (!syserror(tcp)) {
394                 tcp->auxstr = get_sa_handler_str(tcp->u_rval);
395                 return RVAL_HEX | RVAL_STR;
396         }
397         return 0;
398 }
399
400 SYS_FUNC(sgetmask)
401 {
402         if (exiting(tcp) && !syserror(tcp)) {
403                 tcp->auxstr = sprint_old_sigmask_val("mask ", tcp->u_rval);
404                 return RVAL_HEX | RVAL_STR;
405         }
406         return 0;
407 }
408
409 SYS_FUNC(sigsuspend)
410 {
411 #ifdef MIPS
412         print_sigset_addr_len(tcp, tcp->u_arg[tcp->s_ent->nargs - 1],
413                               current_wordsize);
414 #else
415         tprint_old_sigmask_val("", tcp->u_arg[tcp->s_ent->nargs - 1]);
416 #endif
417
418         return RVAL_DECODED;
419 }
420
421 #ifdef ALPHA
422 /*
423  * The OSF/1 sigprocmask is different: it doesn't pass in two pointers,
424  * but rather passes in the new bitmask as an argument and then returns
425  * the old bitmask.  This "works" because we only have 64 signals to worry
426  * about.  If you want more, use of the rt_sigprocmask syscall is required.
427  *
428  * Alpha:
429  *      old = osf_sigprocmask(how, new);
430  * Everyone else:
431  *      ret = sigprocmask(how, &new, &old, ...);
432  */
433 SYS_FUNC(osf_sigprocmask)
434 {
435         if (entering(tcp)) {
436                 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
437                 tprintsigmask_val(", ", tcp->u_arg[1]);
438         } else if (!syserror(tcp)) {
439                 tcp->auxstr = sprintsigmask_val("old mask ", tcp->u_rval);
440                 return RVAL_HEX | RVAL_STR;
441         }
442         return 0;
443 }
444
445 #else /* !ALPHA */
446
447 /* "Old" sigprocmask, which operates with word-sized signal masks */
448 SYS_FUNC(sigprocmask)
449 {
450         if (entering(tcp)) {
451                 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
452                 tprints(", ");
453                 print_sigset_addr_len(tcp, tcp->u_arg[1], current_wordsize);
454                 tprints(", ");
455         } else {
456                 print_sigset_addr_len(tcp, tcp->u_arg[2], current_wordsize);
457         }
458         return 0;
459 }
460 #endif /* !ALPHA */
461
462 SYS_FUNC(kill)
463 {
464         tprintf("%d, %s",
465                 (int) tcp->u_arg[0],
466                 signame(tcp->u_arg[1]));
467
468         return RVAL_DECODED;
469 }
470
471 SYS_FUNC(tgkill)
472 {
473         tprintf("%d, %d, %s",
474                 (int) tcp->u_arg[0],
475                 (int) tcp->u_arg[1],
476                 signame(tcp->u_arg[2]));
477
478         return RVAL_DECODED;
479 }
480
481 SYS_FUNC(sigpending)
482 {
483         if (exiting(tcp))
484                 print_sigset_addr_len(tcp, tcp->u_arg[0], current_wordsize);
485         return 0;
486 }
487
488 SYS_FUNC(rt_sigprocmask)
489 {
490         /* Note: arg[3] is the length of the sigset. Kernel requires NSIG_BYTES */
491         if (entering(tcp)) {
492                 printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
493                 tprints(", ");
494                 print_sigset_addr_len(tcp, tcp->u_arg[1], tcp->u_arg[3]);
495                 tprints(", ");
496         } else {
497                 print_sigset_addr_len(tcp, tcp->u_arg[2], tcp->u_arg[3]);
498                 tprintf(", %" PRI_klu, tcp->u_arg[3]);
499         }
500         return 0;
501 }
502
503 /* Structure describing the action to be taken when a signal arrives.  */
504 struct new_sigaction {
505         /* sa_handler may be a libc #define, need to use other name: */
506 #ifdef MIPS
507         unsigned int sa_flags;
508         unsigned long sa_handler__;
509 #else
510         unsigned long sa_handler__;
511         unsigned long sa_flags;
512 #endif /* !MIPS */
513 #if HAVE_SA_RESTORER
514         unsigned long sa_restorer;
515 #endif
516         /* Kernel treats sa_mask as an array of longs. */
517         unsigned long sa_mask[NSIG / sizeof(long)];
518 };
519 /* Same for i386-on-x86_64 and similar cases */
520 struct new_sigaction32 {
521         uint32_t sa_handler__;
522         uint32_t sa_flags;
523 #if HAVE_SA_RESTORER
524         uint32_t sa_restorer;
525 #endif
526         uint32_t sa_mask[2 * (NSIG / sizeof(long))];
527 };
528
529 static void
530 decode_new_sigaction(struct tcb *const tcp, const kernel_ulong_t addr)
531 {
532         struct new_sigaction sa;
533
534 #ifndef current_wordsize
535         if (current_wordsize < sizeof(sa.sa_handler__)) {
536                 struct new_sigaction32 sa32;
537
538                 if (umove_or_printaddr(tcp, addr, &sa32))
539                         return;
540
541                 memset(&sa, 0, sizeof(sa));
542                 sa.sa_handler__ = sa32.sa_handler__;
543                 sa.sa_flags     = sa32.sa_flags;
544 #if HAVE_SA_RESTORER && defined SA_RESTORER
545                 sa.sa_restorer  = sa32.sa_restorer;
546 #endif
547                 /* Kernel treats sa_mask as an array of longs.
548                  * For 32-bit process, "long" is uint32_t, thus, for example,
549                  * 32th bit in sa_mask will end up as bit 0 in sa_mask[1].
550                  * But for (64-bit) kernel, 32th bit in sa_mask is
551                  * 32th bit in 0th (64-bit) long!
552                  * For little-endian, it's the same.
553                  * For big-endian, we swap 32-bit words.
554                  */
555                 sa.sa_mask[0] = ULONG_LONG(sa32.sa_mask[0], sa32.sa_mask[1]);
556         } else
557 #endif
558         if (umove_or_printaddr(tcp, addr, &sa))
559                 return;
560
561         tprints("{sa_handler=");
562         print_sa_handler(sa.sa_handler__);
563         tprints(", sa_mask=");
564         /*
565          * Sigset size is in tcp->u_arg[4] (SPARC)
566          * or in tcp->u_arg[3] (all other),
567          * but kernel won't handle sys_rt_sigaction
568          * with wrong sigset size (just returns EINVAL instead).
569          * We just fetch the right size, which is NSIG_BYTES.
570          */
571         tprintsigmask_val("", sa.sa_mask);
572         tprints(", sa_flags=");
573
574         printflags(sigact_flags, sa.sa_flags, "SA_???");
575 #if HAVE_SA_RESTORER && defined SA_RESTORER
576         if (sa.sa_flags & SA_RESTORER) {
577                 tprints(", sa_restorer=");
578                 printaddr(sa.sa_restorer);
579         }
580 #endif
581         tprints("}");
582 }
583
584 SYS_FUNC(rt_sigaction)
585 {
586         if (entering(tcp)) {
587                 printsignal(tcp->u_arg[0]);
588                 tprints(", ");
589                 decode_new_sigaction(tcp, tcp->u_arg[1]);
590                 tprints(", ");
591         } else {
592                 decode_new_sigaction(tcp, tcp->u_arg[2]);
593 #if defined(SPARC) || defined(SPARC64)
594                 tprintf(", %#" PRI_klx ", %" PRI_klu, tcp->u_arg[3], tcp->u_arg[4]);
595 #elif defined(ALPHA)
596                 tprintf(", %" PRI_klu ", %#" PRI_klx, tcp->u_arg[3], tcp->u_arg[4]);
597 #else
598                 tprintf(", %" PRI_klu, tcp->u_arg[3]);
599 #endif
600         }
601         return 0;
602 }
603
604 SYS_FUNC(rt_sigpending)
605 {
606         if (exiting(tcp)) {
607                 /*
608                  * One of the few syscalls where sigset size (arg[1])
609                  * is allowed to be <= NSIG_BYTES, not strictly ==.
610                  * This allows non-rt sigpending() syscall
611                  * to reuse rt_sigpending() code in kernel.
612                  */
613                 print_sigset_addr_len_limit(tcp, tcp->u_arg[0],
614                                             tcp->u_arg[1], 1);
615                 tprintf(", %" PRI_klu, tcp->u_arg[1]);
616         }
617         return 0;
618 }
619
620 SYS_FUNC(rt_sigsuspend)
621 {
622         /* NB: kernel requires arg[1] == NSIG_BYTES */
623         print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[1]);
624         tprintf(", %" PRI_klu, tcp->u_arg[1]);
625
626         return RVAL_DECODED;
627 }
628
629 static void
630 print_sigqueueinfo(struct tcb *const tcp, const int sig,
631                    const kernel_ulong_t addr)
632 {
633         printsignal(sig);
634         tprints(", ");
635         printsiginfo_at(tcp, addr);
636 }
637
638 SYS_FUNC(rt_sigqueueinfo)
639 {
640         tprintf("%d, ", (int) tcp->u_arg[0]);
641         print_sigqueueinfo(tcp, tcp->u_arg[1], tcp->u_arg[2]);
642
643         return RVAL_DECODED;
644 }
645
646 SYS_FUNC(rt_tgsigqueueinfo)
647 {
648         tprintf("%d, %d, ", (int) tcp->u_arg[0], (int) tcp->u_arg[1]);
649         print_sigqueueinfo(tcp, tcp->u_arg[2], tcp->u_arg[3]);
650
651         return RVAL_DECODED;
652 }
653
654 SYS_FUNC(rt_sigtimedwait)
655 {
656         /* NB: kernel requires arg[3] == NSIG_BYTES */
657         if (entering(tcp)) {
658                 print_sigset_addr_len(tcp, tcp->u_arg[0], tcp->u_arg[3]);
659                 tprints(", ");
660                 if (!(tcp->u_arg[1] && verbose(tcp))) {
661                         /*
662                          * This is the only "return" parameter,
663                          * if we are not going to fetch it on exit,
664                          * decode all parameters on entry.
665                          */
666                         printaddr(tcp->u_arg[1]);
667                         tprints(", ");
668                         print_timespec(tcp, tcp->u_arg[2]);
669                         tprintf(", %" PRI_klu, tcp->u_arg[3]);
670                 } else {
671                         char *sts = xstrdup(sprint_timespec(tcp, tcp->u_arg[2]));
672                         set_tcb_priv_data(tcp, sts, free);
673                 }
674         } else {
675                 if (tcp->u_arg[1] && verbose(tcp)) {
676                         printsiginfo_at(tcp, tcp->u_arg[1]);
677                         tprints(", ");
678                         tprints(get_tcb_priv_data(tcp));
679                         tprintf(", %" PRI_klu, tcp->u_arg[3]);
680                 }
681
682                 if (!syserror(tcp) && tcp->u_rval) {
683                         tcp->auxstr = signame(tcp->u_rval);
684                         return RVAL_STR;
685                 }
686         }
687         return 0;
688 };
689
690 SYS_FUNC(restart_syscall)
691 {
692         tprintf("<... resuming interrupted %s ...>",
693                 tcp->s_prev_ent ? tcp->s_prev_ent->sys_name : "system call");
694
695         return RVAL_DECODED;
696 }