1 | //===-- LinuxSignals.cpp --------------------------------------------------===// |
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 "LinuxSignals.h" |
10 | |
11 | #ifdef __linux__ |
12 | #include <csignal> |
13 | |
14 | #ifndef SEGV_BNDERR |
15 | #define SEGV_BNDERR 3 |
16 | #endif |
17 | #ifndef SEGV_MTEAERR |
18 | #define SEGV_MTEAERR 8 |
19 | #endif |
20 | #ifndef SEGV_MTESERR |
21 | #define SEGV_MTESERR 9 |
22 | #endif |
23 | |
24 | #define ADD_SIGCODE(signal_name, signal_value, code_name, code_value, ...) \ |
25 | static_assert(signal_name == signal_value, \ |
26 | "Value mismatch for signal number " #signal_name); \ |
27 | static_assert(code_name == code_value, \ |
28 | "Value mismatch for signal code " #code_name); \ |
29 | AddSignalCode(signal_value, code_value, __VA_ARGS__) |
30 | #else |
31 | #define ADD_SIGCODE(signal_name, signal_value, code_name, code_value, ...) \ |
32 | AddSignalCode(signal_value, code_value, __VA_ARGS__) |
33 | #endif /* ifdef __linux__ */ |
34 | |
35 | using namespace lldb_private; |
36 | |
37 | LinuxSignals::LinuxSignals() : UnixSignals() { Reset(); } |
38 | |
39 | void LinuxSignals::Reset() { |
40 | m_signals.clear(); |
41 | // clang-format off |
42 | // SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION |
43 | // ====== ============== ======== ====== ====== =================================================== |
44 | AddSignal(signo: 1, name: "SIGHUP" , default_suppress: false, default_stop: true, default_notify: true, description: "hangup" ); |
45 | AddSignal(signo: 2, name: "SIGINT" , default_suppress: true, default_stop: true, default_notify: true, description: "interrupt" ); |
46 | AddSignal(signo: 3, name: "SIGQUIT" , default_suppress: false, default_stop: true, default_notify: true, description: "quit" ); |
47 | |
48 | AddSignal(signo: 4, name: "SIGILL" , default_suppress: false, default_stop: true, default_notify: true, description: "illegal instruction" ); |
49 | ADD_SIGCODE(SIGILL, 4, ILL_ILLOPC, 1, "illegal opcode" ); |
50 | ADD_SIGCODE(SIGILL, 4, ILL_ILLOPN, 2, "illegal operand" ); |
51 | ADD_SIGCODE(SIGILL, 4, ILL_ILLADR, 3, "illegal addressing mode" ); |
52 | ADD_SIGCODE(SIGILL, 4, ILL_ILLTRP, 4, "illegal trap" ); |
53 | ADD_SIGCODE(SIGILL, 4, ILL_PRVOPC, 5, "privileged opcode" ); |
54 | ADD_SIGCODE(SIGILL, 4, ILL_PRVREG, 6, "privileged register" ); |
55 | ADD_SIGCODE(SIGILL, 4, ILL_COPROC, 7, "coprocessor error" ); |
56 | ADD_SIGCODE(SIGILL, 4, ILL_BADSTK, 8, "internal stack error" ); |
57 | |
58 | AddSignal(signo: 5, name: "SIGTRAP" , default_suppress: true, default_stop: true, default_notify: true, description: "trace trap (not reset when caught)" ); |
59 | AddSignal(signo: 6, name: "SIGABRT" , default_suppress: false, default_stop: true, default_notify: true, description: "abort()/IOT trap" , alias: "SIGIOT" ); |
60 | |
61 | AddSignal(signo: 7, name: "SIGBUS" , default_suppress: false, default_stop: true, default_notify: true, description: "bus error" ); |
62 | ADD_SIGCODE(SIGBUS, 7, BUS_ADRALN, 1, "illegal alignment" ); |
63 | ADD_SIGCODE(SIGBUS, 7, BUS_ADRERR, 2, "illegal address" ); |
64 | ADD_SIGCODE(SIGBUS, 7, BUS_OBJERR, 3, "hardware error" ); |
65 | |
66 | AddSignal(signo: 8, name: "SIGFPE" , default_suppress: false, default_stop: true, default_notify: true, description: "floating point exception" ); |
67 | ADD_SIGCODE(SIGFPE, 8, FPE_INTDIV, 1, "integer divide by zero" ); |
68 | ADD_SIGCODE(SIGFPE, 8, FPE_INTOVF, 2, "integer overflow" ); |
69 | ADD_SIGCODE(SIGFPE, 8, FPE_FLTDIV, 3, "floating point divide by zero" ); |
70 | ADD_SIGCODE(SIGFPE, 8, FPE_FLTOVF, 4, "floating point overflow" ); |
71 | ADD_SIGCODE(SIGFPE, 8, FPE_FLTUND, 5, "floating point underflow" ); |
72 | ADD_SIGCODE(SIGFPE, 8, FPE_FLTRES, 6, "floating point inexact result" ); |
73 | ADD_SIGCODE(SIGFPE, 8, FPE_FLTINV, 7, "floating point invalid operation" ); |
74 | ADD_SIGCODE(SIGFPE, 8, FPE_FLTSUB, 8, "subscript out of range" ); |
75 | |
76 | AddSignal(signo: 9, name: "SIGKILL" , default_suppress: false, default_stop: true, default_notify: true, description: "kill" ); |
77 | AddSignal(signo: 10, name: "SIGUSR1" , default_suppress: false, default_stop: true, default_notify: true, description: "user defined signal 1" ); |
78 | |
79 | AddSignal(signo: 11, name: "SIGSEGV" , default_suppress: false, default_stop: true, default_notify: true, description: "segmentation violation" ); |
80 | ADD_SIGCODE(SIGSEGV, 11, SEGV_MAPERR, 1, "address not mapped to object" , SignalCodePrintOption::Address); |
81 | ADD_SIGCODE(SIGSEGV, 11, SEGV_ACCERR, 2, "invalid permissions for mapped object" , SignalCodePrintOption::Address); |
82 | ADD_SIGCODE(SIGSEGV, 11, SEGV_BNDERR, 3, "failed address bounds checks" , SignalCodePrintOption::Bounds); |
83 | ADD_SIGCODE(SIGSEGV, 11, SEGV_MTEAERR, 8, "async tag check fault" ); |
84 | ADD_SIGCODE(SIGSEGV, 11, SEGV_MTESERR, 9, "sync tag check fault" , SignalCodePrintOption::Address); |
85 | // Some platforms will occasionally send nonstandard spurious SI_KERNEL |
86 | // codes. One way to get this is via unaligned SIMD loads. Treat it as invalid address. |
87 | ADD_SIGCODE(SIGSEGV, 11, SI_KERNEL, 0x80, "invalid address" , SignalCodePrintOption::Address); |
88 | |
89 | AddSignal(signo: 12, name: "SIGUSR2" , default_suppress: false, default_stop: true, default_notify: true, description: "user defined signal 2" ); |
90 | AddSignal(signo: 13, name: "SIGPIPE" , default_suppress: false, default_stop: true, default_notify: true, description: "write to pipe with reading end closed" ); |
91 | AddSignal(signo: 14, name: "SIGALRM" , default_suppress: false, default_stop: false, default_notify: false, description: "alarm" ); |
92 | AddSignal(signo: 15, name: "SIGTERM" , default_suppress: false, default_stop: true, default_notify: true, description: "termination requested" ); |
93 | AddSignal(signo: 16, name: "SIGSTKFLT" , default_suppress: false, default_stop: true, default_notify: true, description: "stack fault" ); |
94 | AddSignal(signo: 17, name: "SIGCHLD" , default_suppress: false, default_stop: false, default_notify: true, description: "child status has changed" , alias: "SIGCLD" ); |
95 | AddSignal(signo: 18, name: "SIGCONT" , default_suppress: false, default_stop: false, default_notify: true, description: "process continue" ); |
96 | AddSignal(signo: 19, name: "SIGSTOP" , default_suppress: true, default_stop: true, default_notify: true, description: "process stop" ); |
97 | AddSignal(signo: 20, name: "SIGTSTP" , default_suppress: false, default_stop: true, default_notify: true, description: "tty stop" ); |
98 | AddSignal(signo: 21, name: "SIGTTIN" , default_suppress: false, default_stop: true, default_notify: true, description: "background tty read" ); |
99 | AddSignal(signo: 22, name: "SIGTTOU" , default_suppress: false, default_stop: true, default_notify: true, description: "background tty write" ); |
100 | AddSignal(signo: 23, name: "SIGURG" , default_suppress: false, default_stop: true, default_notify: true, description: "urgent data on socket" ); |
101 | AddSignal(signo: 24, name: "SIGXCPU" , default_suppress: false, default_stop: true, default_notify: true, description: "CPU resource exceeded" ); |
102 | AddSignal(signo: 25, name: "SIGXFSZ" , default_suppress: false, default_stop: true, default_notify: true, description: "file size limit exceeded" ); |
103 | AddSignal(signo: 26, name: "SIGVTALRM" , default_suppress: false, default_stop: true, default_notify: true, description: "virtual time alarm" ); |
104 | AddSignal(signo: 27, name: "SIGPROF" , default_suppress: false, default_stop: false, default_notify: false, description: "profiling time alarm" ); |
105 | AddSignal(signo: 28, name: "SIGWINCH" , default_suppress: false, default_stop: true, default_notify: true, description: "window size changes" ); |
106 | AddSignal(signo: 29, name: "SIGIO" , default_suppress: false, default_stop: true, default_notify: true, description: "input/output ready/Pollable event" , alias: "SIGPOLL" ); |
107 | AddSignal(signo: 30, name: "SIGPWR" , default_suppress: false, default_stop: true, default_notify: true, description: "power failure" ); |
108 | AddSignal(signo: 31, name: "SIGSYS" , default_suppress: false, default_stop: true, default_notify: true, description: "invalid system call" ); |
109 | AddSignal(signo: 32, name: "SIG32" , default_suppress: false, default_stop: false, default_notify: false, description: "threading library internal signal 1" ); |
110 | AddSignal(signo: 33, name: "SIG33" , default_suppress: false, default_stop: false, default_notify: false, description: "threading library internal signal 2" ); |
111 | AddSignal(signo: 34, name: "SIGRTMIN" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 0" ); |
112 | AddSignal(signo: 35, name: "SIGRTMIN+1" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 1" ); |
113 | AddSignal(signo: 36, name: "SIGRTMIN+2" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 2" ); |
114 | AddSignal(signo: 37, name: "SIGRTMIN+3" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 3" ); |
115 | AddSignal(signo: 38, name: "SIGRTMIN+4" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 4" ); |
116 | AddSignal(signo: 39, name: "SIGRTMIN+5" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 5" ); |
117 | AddSignal(signo: 40, name: "SIGRTMIN+6" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 6" ); |
118 | AddSignal(signo: 41, name: "SIGRTMIN+7" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 7" ); |
119 | AddSignal(signo: 42, name: "SIGRTMIN+8" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 8" ); |
120 | AddSignal(signo: 43, name: "SIGRTMIN+9" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 9" ); |
121 | AddSignal(signo: 44, name: "SIGRTMIN+10" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 10" ); |
122 | AddSignal(signo: 45, name: "SIGRTMIN+11" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 11" ); |
123 | AddSignal(signo: 46, name: "SIGRTMIN+12" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 12" ); |
124 | AddSignal(signo: 47, name: "SIGRTMIN+13" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 13" ); |
125 | AddSignal(signo: 48, name: "SIGRTMIN+14" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 14" ); |
126 | AddSignal(signo: 49, name: "SIGRTMIN+15" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 15" ); |
127 | AddSignal(signo: 50, name: "SIGRTMAX-14" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 16" ); // switching to SIGRTMAX-xxx to match "kill -l" output |
128 | AddSignal(signo: 51, name: "SIGRTMAX-13" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 17" ); |
129 | AddSignal(signo: 52, name: "SIGRTMAX-12" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 18" ); |
130 | AddSignal(signo: 53, name: "SIGRTMAX-11" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 19" ); |
131 | AddSignal(signo: 54, name: "SIGRTMAX-10" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 20" ); |
132 | AddSignal(signo: 55, name: "SIGRTMAX-9" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 21" ); |
133 | AddSignal(signo: 56, name: "SIGRTMAX-8" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 22" ); |
134 | AddSignal(signo: 57, name: "SIGRTMAX-7" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 23" ); |
135 | AddSignal(signo: 58, name: "SIGRTMAX-6" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 24" ); |
136 | AddSignal(signo: 59, name: "SIGRTMAX-5" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 25" ); |
137 | AddSignal(signo: 60, name: "SIGRTMAX-4" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 26" ); |
138 | AddSignal(signo: 61, name: "SIGRTMAX-3" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 27" ); |
139 | AddSignal(signo: 62, name: "SIGRTMAX-2" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 28" ); |
140 | AddSignal(signo: 63, name: "SIGRTMAX-1" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 29" ); |
141 | AddSignal(signo: 64, name: "SIGRTMAX" , default_suppress: false, default_stop: false, default_notify: false, description: "real time signal 30" ); |
142 | // clang-format on |
143 | } |
144 | |