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