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