1 //===-- NetBSDSignals.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 "NetBSDSignals.h"
10
11 #ifdef __NetBSD__
12 #include <csignal>
13
14 #define ADD_SIGCODE(signal_name, signal_value, code_name, code_value, ...) \
15 static_assert(signal_name == signal_value, \
16 "Value mismatch for signal number " #signal_name); \
17 static_assert(code_name == code_value, \
18 "Value mismatch for signal code " #code_name); \
19 AddSignalCode(signal_value, code_value, __VA_ARGS__)
20 #else
21 #define ADD_SIGCODE(signal_name, signal_value, code_name, code_value, ...) \
22 AddSignalCode(signal_value, code_value, __VA_ARGS__)
23 #endif /* ifdef __NetBSD */
24
25 using namespace lldb_private;
26
NetBSDSignals()27 NetBSDSignals::NetBSDSignals() : UnixSignals() { Reset(); }
28
Reset()29 void NetBSDSignals::Reset() {
30 UnixSignals::Reset();
31
32 // clang-format off
33 // SIGILL
34 ADD_SIGCODE(SIGILL, 4, ILL_ILLOPC, 1, "illegal opcode");
35 ADD_SIGCODE(SIGILL, 4, ILL_ILLOPN, 2, "illegal operand");
36 ADD_SIGCODE(SIGILL, 4, ILL_ILLADR, 3, "illegal addressing mode");
37 ADD_SIGCODE(SIGILL, 4, ILL_ILLTRP, 4, "illegal trap");
38 ADD_SIGCODE(SIGILL, 4, ILL_PRVOPC, 5, "privileged opcode");
39 ADD_SIGCODE(SIGILL, 4, ILL_PRVREG, 6, "privileged register");
40 ADD_SIGCODE(SIGILL, 4, ILL_COPROC, 7, "coprocessor error");
41 ADD_SIGCODE(SIGILL, 4, ILL_BADSTK, 8, "internal stack error");
42
43 // SIGFPE
44 ADD_SIGCODE(SIGFPE, 8, FPE_INTDIV, 1, "integer divide by zero");
45 ADD_SIGCODE(SIGFPE, 8, FPE_INTOVF, 2, "integer overflow");
46 ADD_SIGCODE(SIGFPE, 8, FPE_FLTDIV, 3, "floating point divide by zero");
47 ADD_SIGCODE(SIGFPE, 8, FPE_FLTOVF, 4, "floating point overflow");
48 ADD_SIGCODE(SIGFPE, 8, FPE_FLTUND, 5, "floating point underflow");
49 ADD_SIGCODE(SIGFPE, 8, FPE_FLTRES, 6, "floating point inexact result");
50 ADD_SIGCODE(SIGFPE, 8, FPE_FLTINV, 7, "invalid floating point operation");
51 ADD_SIGCODE(SIGFPE, 8, FPE_FLTSUB, 8, "subscript out of range");
52
53 // SIGBUS
54 ADD_SIGCODE(SIGBUS, 10, BUS_ADRALN, 1, "invalid address alignment");
55 ADD_SIGCODE(SIGBUS, 10, BUS_ADRERR, 2, "non-existent physical address");
56 ADD_SIGCODE(SIGBUS, 10, BUS_OBJERR, 3, "object specific hardware error");
57
58 // SIGSEGV
59 ADD_SIGCODE(SIGSEGV, 11, SEGV_MAPERR, 1, "address not mapped to object",
60 SignalCodePrintOption::Address);
61 ADD_SIGCODE(SIGSEGV, 11, SEGV_ACCERR, 2, "invalid permissions for mapped object",
62 SignalCodePrintOption::Address);
63
64 // SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION
65 // ===== ============== ======== ====== ====== ========================
66 AddSignal(32, "SIGPWR", false, true, true, "power fail/restart (not reset when caught)");
67 AddSignal(33, "SIGRTMIN", false, false, false, "real time signal 0");
68 AddSignal(34, "SIGRTMIN+1", false, false, false, "real time signal 1");
69 AddSignal(35, "SIGRTMIN+2", false, false, false, "real time signal 2");
70 AddSignal(36, "SIGRTMIN+3", false, false, false, "real time signal 3");
71 AddSignal(37, "SIGRTMIN+4", false, false, false, "real time signal 4");
72 AddSignal(38, "SIGRTMIN+5", false, false, false, "real time signal 5");
73 AddSignal(39, "SIGRTMIN+6", false, false, false, "real time signal 6");
74 AddSignal(40, "SIGRTMIN+7", false, false, false, "real time signal 7");
75 AddSignal(41, "SIGRTMIN+8", false, false, false, "real time signal 8");
76 AddSignal(42, "SIGRTMIN+9", false, false, false, "real time signal 9");
77 AddSignal(43, "SIGRTMIN+10", false, false, false, "real time signal 10");
78 AddSignal(44, "SIGRTMIN+11", false, false, false, "real time signal 11");
79 AddSignal(45, "SIGRTMIN+12", false, false, false, "real time signal 12");
80 AddSignal(46, "SIGRTMIN+13", false, false, false, "real time signal 13");
81 AddSignal(47, "SIGRTMIN+14", false, false, false, "real time signal 14");
82 AddSignal(48, "SIGRTMIN+15", false, false, false, "real time signal 15");
83 AddSignal(49, "SIGRTMIN-14", false, false, false, "real time signal 16");
84 AddSignal(50, "SIGRTMAX-13", false, false, false, "real time signal 17");
85 AddSignal(51, "SIGRTMAX-12", false, false, false, "real time signal 18");
86 AddSignal(52, "SIGRTMAX-11", false, false, false, "real time signal 19");
87 AddSignal(53, "SIGRTMAX-10", false, false, false, "real time signal 20");
88 AddSignal(54, "SIGRTMAX-9", false, false, false, "real time signal 21");
89 AddSignal(55, "SIGRTMAX-8", false, false, false, "real time signal 22");
90 AddSignal(56, "SIGRTMAX-7", false, false, false, "real time signal 23");
91 AddSignal(57, "SIGRTMAX-6", false, false, false, "real time signal 24");
92 AddSignal(58, "SIGRTMAX-5", false, false, false, "real time signal 25");
93 AddSignal(59, "SIGRTMAX-4", false, false, false, "real time signal 26");
94 AddSignal(60, "SIGRTMAX-3", false, false, false, "real time signal 27");
95 AddSignal(61, "SIGRTMAX-2", false, false, false, "real time signal 28");
96 AddSignal(62, "SIGRTMAX-1", false, false, false, "real time signal 29");
97 AddSignal(63, "SIGRTMAX", false, false, false, "real time signal 30");
98 // clang-format on
99 }
100