Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

signal.c 16KB

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