LLDB mainline
LinuxSignals.cpp
Go to the documentation of this file.
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
35using namespace lldb_private;
36
38
40 m_signals.clear();
41 // clang-format off
42 // SIGNO NAME SUPPRESS STOP NOTIFY DESCRIPTION
43 // ====== ============== ======== ====== ====== ===================================================
44 AddSignal(1, "SIGHUP", false, true, true, "hangup");
45 AddSignal(2, "SIGINT", true, true, true, "interrupt");
46 AddSignal(3, "SIGQUIT", false, true, true, "quit");
47
48 AddSignal(4, "SIGILL", false, true, true, "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(5, "SIGTRAP", true, true, true, "trace trap (not reset when caught)");
59 AddSignal(6, "SIGABRT", false, true, true, "abort()/IOT trap", "SIGIOT");
60
61 AddSignal(7, "SIGBUS", false, true, true, "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(8, "SIGFPE", false, true, true, "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(9, "SIGKILL", false, true, true, "kill");
77 AddSignal(10, "SIGUSR1", false, true, true, "user defined signal 1");
78
79 AddSignal(11, "SIGSEGV", false, true, true, "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(12, "SIGUSR2", false, true, true, "user defined signal 2");
90 AddSignal(13, "SIGPIPE", false, true, true, "write to pipe with reading end closed");
91 AddSignal(14, "SIGALRM", false, false, false, "alarm");
92 AddSignal(15, "SIGTERM", false, true, true, "termination requested");
93 AddSignal(16, "SIGSTKFLT", false, true, true, "stack fault");
94 AddSignal(17, "SIGCHLD", false, false, true, "child status has changed", "SIGCLD");
95 AddSignal(18, "SIGCONT", false, false, true, "process continue");
96 AddSignal(19, "SIGSTOP", true, true, true, "process stop");
97 AddSignal(20, "SIGTSTP", false, true, true, "tty stop");
98 AddSignal(21, "SIGTTIN", false, true, true, "background tty read");
99 AddSignal(22, "SIGTTOU", false, true, true, "background tty write");
100 AddSignal(23, "SIGURG", false, true, true, "urgent data on socket");
101 AddSignal(24, "SIGXCPU", false, true, true, "CPU resource exceeded");
102 AddSignal(25, "SIGXFSZ", false, true, true, "file size limit exceeded");
103 AddSignal(26, "SIGVTALRM", false, true, true, "virtual time alarm");
104 AddSignal(27, "SIGPROF", false, false, false, "profiling time alarm");
105 AddSignal(28, "SIGWINCH", false, true, true, "window size changes");
106 AddSignal(29, "SIGIO", false, true, true, "input/output ready/Pollable event", "SIGPOLL");
107 AddSignal(30, "SIGPWR", false, true, true, "power failure");
108 AddSignal(31, "SIGSYS", false, true, true, "invalid system call");
109 AddSignal(32, "SIG32", false, false, false, "threading library internal signal 1");
110 AddSignal(33, "SIG33", false, false, false, "threading library internal signal 2");
111 AddSignal(34, "SIGRTMIN", false, false, false, "real time signal 0");
112 AddSignal(35, "SIGRTMIN+1", false, false, false, "real time signal 1");
113 AddSignal(36, "SIGRTMIN+2", false, false, false, "real time signal 2");
114 AddSignal(37, "SIGRTMIN+3", false, false, false, "real time signal 3");
115 AddSignal(38, "SIGRTMIN+4", false, false, false, "real time signal 4");
116 AddSignal(39, "SIGRTMIN+5", false, false, false, "real time signal 5");
117 AddSignal(40, "SIGRTMIN+6", false, false, false, "real time signal 6");
118 AddSignal(41, "SIGRTMIN+7", false, false, false, "real time signal 7");
119 AddSignal(42, "SIGRTMIN+8", false, false, false, "real time signal 8");
120 AddSignal(43, "SIGRTMIN+9", false, false, false, "real time signal 9");
121 AddSignal(44, "SIGRTMIN+10", false, false, false, "real time signal 10");
122 AddSignal(45, "SIGRTMIN+11", false, false, false, "real time signal 11");
123 AddSignal(46, "SIGRTMIN+12", false, false, false, "real time signal 12");
124 AddSignal(47, "SIGRTMIN+13", false, false, false, "real time signal 13");
125 AddSignal(48, "SIGRTMIN+14", false, false, false, "real time signal 14");
126 AddSignal(49, "SIGRTMIN+15", false, false, false, "real time signal 15");
127 AddSignal(50, "SIGRTMAX-14", false, false, false, "real time signal 16"); // switching to SIGRTMAX-xxx to match "kill -l" output
128 AddSignal(51, "SIGRTMAX-13", false, false, false, "real time signal 17");
129 AddSignal(52, "SIGRTMAX-12", false, false, false, "real time signal 18");
130 AddSignal(53, "SIGRTMAX-11", false, false, false, "real time signal 19");
131 AddSignal(54, "SIGRTMAX-10", false, false, false, "real time signal 20");
132 AddSignal(55, "SIGRTMAX-9", false, false, false, "real time signal 21");
133 AddSignal(56, "SIGRTMAX-8", false, false, false, "real time signal 22");
134 AddSignal(57, "SIGRTMAX-7", false, false, false, "real time signal 23");
135 AddSignal(58, "SIGRTMAX-6", false, false, false, "real time signal 24");
136 AddSignal(59, "SIGRTMAX-5", false, false, false, "real time signal 25");
137 AddSignal(60, "SIGRTMAX-4", false, false, false, "real time signal 26");
138 AddSignal(61, "SIGRTMAX-3", false, false, false, "real time signal 27");
139 AddSignal(62, "SIGRTMAX-2", false, false, false, "real time signal 28");
140 AddSignal(63, "SIGRTMAX-1", false, false, false, "real time signal 29");
141 AddSignal(64, "SIGRTMAX", false, false, false, "real time signal 30");
142 // clang-format on
143}
#define ADD_SIGCODE(signal_name, signal_value, code_name, code_value,...)
#define SEGV_MTESERR
void AddSignal(int signo, llvm::StringRef name, bool default_suppress, bool default_stop, bool default_notify, llvm::StringRef description, llvm::StringRef alias=llvm::StringRef())
A class that represents a running process on the host machine.