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-1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6 * Copyright (c) 2001 John Hughes <john@Calva.COM>
7 * Copyright (c) 2013 Denys Vlasenko <vda.linux@googlemail.com>
8 * Copyright (c) 2011-2015 Dmitry V. Levin <ldv@altlinux.org>
9 * Copyright (c) 2015 Elvira Khabirova <lineprinter0@gmail.com>
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
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.
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.
37 #include DEF_MPERS_TYPE(siginfo_t)
40 #include <linux/audit.h>
45 #include "printsiginfo.h"
48 #include "xlat/audit_arch.h"
49 #include "xlat/sigbus_codes.h"
50 #include "xlat/sigchld_codes.h"
51 #include "xlat/sigfpe_codes.h"
52 #include "xlat/sigill_codes.h"
53 #include "xlat/siginfo_codes.h"
54 #include "xlat/sigpoll_codes.h"
55 #include "xlat/sigprof_codes.h"
56 #include "xlat/sigsegv_codes.h"
57 #include "xlat/sigsys_codes.h"
58 #include "xlat/sigtrap_codes.h"
61 # include "xlat/sigemt_codes.h"
65 # define SI_FROMUSER(sip) ((sip)->si_code <= 0)
69 printsigsource(const siginfo_t *sip)
71 tprintf(", si_pid=%u, si_uid=%u",
72 (unsigned int) sip->si_pid,
73 (unsigned int) sip->si_uid);
77 printsigval(const siginfo_t *sip)
79 tprintf(", si_value={int=%d, ptr=%#lx}",
80 sip->si_int, (unsigned long) sip->si_ptr);
84 print_si_code(int si_signo, unsigned int si_code)
86 const char *code = xlookup(siginfo_codes, si_code);
91 code = xlookup(sigtrap_codes, si_code);
94 code = xlookup(sigchld_codes, si_code);
97 code = xlookup(sigpoll_codes, si_code);
100 code = xlookup(sigprof_codes, si_code);
103 code = xlookup(sigill_codes, si_code);
107 code = xlookup(sigemt_codes, si_code);
111 code = xlookup(sigfpe_codes, si_code);
114 code = xlookup(sigsegv_codes, si_code);
117 code = xlookup(sigbus_codes, si_code);
120 code = xlookup(sigsys_codes, si_code);
128 tprintf("%#x", si_code);
132 print_si_info(const siginfo_t *sip)
135 tprints(", si_errno=");
136 if ((unsigned) sip->si_errno < nerrnos
137 && errnoent[sip->si_errno])
138 tprints(errnoent[sip->si_errno]);
140 tprintf("%d", sip->si_errno);
143 if (SI_FROMUSER(sip)) {
144 switch (sip->si_code) {
151 #if defined HAVE_SIGINFO_T_SI_TIMERID && defined HAVE_SIGINFO_T_SI_OVERRUN
153 tprintf(", si_timerid=%#x, si_overrun=%d",
154 sip->si_timerid, sip->si_overrun);
165 switch (sip->si_signo) {
168 tprints(", si_status=");
169 if (sip->si_code == CLD_EXITED)
170 tprintf("%d", sip->si_status);
172 printsignal(sip->si_status);
173 tprintf(", si_utime=%llu, si_stime=%llu",
174 (unsigned long long) sip->si_utime,
175 (unsigned long long) sip->si_stime);
177 case SIGILL: case SIGFPE:
178 case SIGSEGV: case SIGBUS:
179 tprintf(", si_addr=%#lx",
180 (unsigned long) sip->si_addr);
183 switch (sip->si_code) {
184 case POLL_IN: case POLL_OUT: case POLL_MSG:
185 tprintf(", si_band=%ld",
186 (long) sip->si_band);
190 #ifdef HAVE_SIGINFO_T_SI_SYSCALL
192 tprintf(", si_call_addr=%#lx, si_syscall=__NR_%s, si_arch=",
193 (unsigned long) sip->si_call_addr,
194 syscall_name((unsigned) sip->si_syscall));
195 printxval(audit_arch, sip->si_arch, "AUDIT_ARCH_???");
199 if (sip->si_pid || sip->si_uid)
211 printsiginfo(const siginfo_t *sip)
213 if (sip->si_signo == 0) {
217 tprints("{si_signo=");
218 printsignal(sip->si_signo);
220 tprints(", si_code=");
221 print_si_code(sip->si_signo, sip->si_code);
224 if (sip->si_code != SI_NOINFO)
231 MPERS_PRINTER_DECL(void, printsiginfo_at)(struct tcb *tcp, long addr)
235 if (!umove_or_printaddr(tcp, addr, &si))
240 print_siginfo_t(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
242 printsiginfo((const siginfo_t *) elem_buf);
246 MPERS_PRINTER_DECL(void, print_siginfo_array)(struct tcb *tcp, unsigned long addr, unsigned long len)
250 print_array(tcp, addr, len, &si, sizeof(si),
251 umoven_or_printaddr, print_siginfo_t, 0);