1//===-- generate_siginfo_linux.c ------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include <signal.h>
10#include <stddef.h>
11#include <stdio.h>
12
13siginfo_t siginfo;
14
15#define P(member) \
16 printf(" {\"%s\", %zd, %zd},\n", #member, \
17 offsetof(siginfo_t, member), sizeof(siginfo.member));
18
19// undef annoying "POSIX friendliness" macros
20#undef si_pid
21#undef si_uid
22#undef si_overrun
23#undef si_status
24#undef si_utime
25#undef si_stime
26#undef si_addr
27#undef si_addr_lsb
28#undef si_band
29#undef si_fd
30
31int main() {
32 printf(format: " ExpectFields(siginfo_type,\n");
33 printf(format: " {\n");
34
35#if !defined(__NetBSD__)
36 P(si_signo);
37 P(si_errno);
38 P(si_code);
39
40#if defined(__GLIBC__)
41 P(_sifields._kill.si_pid);
42 P(_sifields._kill.si_uid);
43 P(_sifields._timer.si_tid);
44 P(_sifields._timer.si_overrun);
45 P(_sifields._timer.si_sigval);
46 P(_sifields._rt.si_pid);
47 P(_sifields._rt.si_uid);
48 P(_sifields._rt.si_sigval);
49 P(_sifields._sigchld.si_pid);
50 P(_sifields._sigchld.si_uid);
51 P(_sifields._sigchld.si_status);
52 P(_sifields._sigchld.si_utime);
53 P(_sifields._sigchld.si_stime);
54 P(_sifields._sigfault.si_addr);
55 P(_sifields._sigfault.si_addr_lsb);
56 P(_sifields._sigfault._bounds._addr_bnd._lower);
57 P(_sifields._sigfault._bounds._addr_bnd._upper);
58 P(_sifields._sigfault._bounds._pkey);
59 P(_sifields._sigpoll.si_band);
60 P(_sifields._sigpoll.si_fd);
61 P(_sifields._sigsys._call_addr);
62 P(_sifields._sigsys._syscall);
63 P(_sifields._sigsys._arch);
64#endif // defined(__GLIBC__)
65
66#if defined(__FreeBSD__)
67 // these are top-level fields on FreeBSD
68 P(si_pid);
69 P(si_uid);
70 P(si_status);
71 P(si_addr);
72 P(si_value);
73 P(_reason._fault._trapno);
74 P(_reason._timer._timerid);
75 P(_reason._timer._overrun);
76 P(_reason._mesgq._mqd);
77 P(_reason._poll._band);
78#endif // defined(__FreeBSD__)
79
80#else // defined(__NetBSD__)
81
82 P(_info._signo);
83 P(_info._code);
84 P(_info._errno);
85 P(_info._reason._rt._pid);
86 P(_info._reason._rt._uid);
87 P(_info._reason._rt._value);
88 P(_info._reason._child._pid);
89 P(_info._reason._child._uid);
90 P(_info._reason._child._status);
91 P(_info._reason._child._utime);
92 P(_info._reason._child._stime);
93 P(_info._reason._fault._addr);
94 P(_info._reason._fault._trap);
95 P(_info._reason._fault._trap2);
96 P(_info._reason._fault._trap3);
97 P(_info._reason._poll._band);
98 P(_info._reason._poll._fd);
99 P(_info._reason._syscall._sysnum);
100 P(_info._reason._syscall._retval);
101 P(_info._reason._syscall._error);
102 P(_info._reason._syscall._args);
103 P(_info._reason._ptrace_state._pe_report_event);
104 P(_info._reason._ptrace_state._option._pe_other_pid);
105 P(_info._reason._ptrace_state._option._pe_lwp);
106
107#endif // defined(__NetBSD__)
108
109 printf(format: " });\n");
110
111 return 0;
112}
113

source code of lldb/unittests/Platform/tools/generate_siginfo.c