22 bool default_stop,
bool default_notify,
23 const char *description,
const char *alias)
24 : m_name(name), m_alias(alias), m_description(),
25 m_suppress(default_suppress), m_stop(default_stop),
26 m_notify(default_notify),
27 m_default_suppress(default_suppress), m_default_stop(default_stop),
28 m_default_notify(default_notify) {
35 switch (triple.getOS()) {
36 case llvm::Triple::Linux: {
37 switch (triple.getArch()) {
38 case llvm::Triple::mips:
39 case llvm::Triple::mipsel:
40 case llvm::Triple::mips64:
41 case llvm::Triple::mips64el:
42 return std::make_shared<MipsLinuxSignals>();
44 return std::make_shared<LinuxSignals>();
47 case llvm::Triple::FreeBSD:
48 case llvm::Triple::OpenBSD:
49 return std::make_shared<FreeBSDSignals>();
50 case llvm::Triple::NetBSD:
51 return std::make_shared<NetBSDSignals>();
53 return std::make_shared<UnixSignals>();
58 static lldb::UnixSignalsSP s_unix_signals_sp =
59 Create(HostInfo::GetArchitecture());
60 return s_unix_signals_sp;
82 AddSignal(1,
"SIGHUP",
false,
true,
true,
"hangup");
83 AddSignal(2,
"SIGINT",
true,
true,
true,
"interrupt");
84 AddSignal(3,
"SIGQUIT",
false,
true,
true,
"quit");
85 AddSignal(4,
"SIGILL",
false,
true,
true,
"illegal instruction");
86 AddSignal(5,
"SIGTRAP",
true,
true,
true,
"trace trap (not reset when caught)");
87 AddSignal(6,
"SIGABRT",
false,
true,
true,
"abort()");
88 AddSignal(7,
"SIGEMT",
false,
true,
true,
"pollable event");
89 AddSignal(8,
"SIGFPE",
false,
true,
true,
"floating point exception");
90 AddSignal(9,
"SIGKILL",
false,
true,
true,
"kill");
91 AddSignal(10,
"SIGBUS",
false,
true,
true,
"bus error");
92 AddSignal(11,
"SIGSEGV",
false,
true,
true,
"segmentation violation");
93 AddSignal(12,
"SIGSYS",
false,
true,
true,
"bad argument to system call");
94 AddSignal(13,
"SIGPIPE",
false,
false,
false,
"write on a pipe with no one to read it");
95 AddSignal(14,
"SIGALRM",
false,
false,
false,
"alarm clock");
96 AddSignal(15,
"SIGTERM",
false,
true,
true,
"software termination signal from kill");
97 AddSignal(16,
"SIGURG",
false,
false,
false,
"urgent condition on IO channel");
98 AddSignal(17,
"SIGSTOP",
true,
true,
true,
"sendable stop signal not from tty");
99 AddSignal(18,
"SIGTSTP",
false,
true,
true,
"stop signal from tty");
100 AddSignal(19,
"SIGCONT",
false,
false,
true,
"continue a stopped process");
101 AddSignal(20,
"SIGCHLD",
false,
false,
false,
"to parent on child stop or exit");
102 AddSignal(21,
"SIGTTIN",
false,
true,
true,
"to readers process group upon background tty read");
103 AddSignal(22,
"SIGTTOU",
false,
true,
true,
"to readers process group upon background tty write");
104 AddSignal(23,
"SIGIO",
false,
false,
false,
"input/output possible signal");
105 AddSignal(24,
"SIGXCPU",
false,
true,
true,
"exceeded CPU time limit");
106 AddSignal(25,
"SIGXFSZ",
false,
true,
true,
"exceeded file size limit");
107 AddSignal(26,
"SIGVTALRM",
false,
false,
false,
"virtual time alarm");
108 AddSignal(27,
"SIGPROF",
false,
false,
false,
"profiling time alarm");
109 AddSignal(28,
"SIGWINCH",
false,
false,
false,
"window size changes");
110 AddSignal(29,
"SIGINFO",
false,
true,
true,
"information request");
111 AddSignal(30,
"SIGUSR1",
false,
true,
true,
"user defined signal 1");
112 AddSignal(31,
"SIGUSR2",
false,
true,
true,
"user defined signal 2");
117 bool default_stop,
bool default_notify,
118 const char *description,
const char *alias) {
119 Signal new_signal(name, default_suppress, default_stop, default_notify,
121 m_signals.insert(std::make_pair(signo, new_signal));
126 collection::iterator pos =
m_signals.find(signo);
133 collection::const_iterator pos =
m_signals.find(signo);
137 return pos->second.m_name.GetCString();
153 collection::const_iterator pos, end =
m_signals.end();
154 for (pos =
m_signals.begin(); pos != end; pos++) {
155 if ((const_name == pos->second.m_name) ||
156 (const_name == pos->second.m_alias) ||
163 if (llvm::to_integer(name, signo))
176 collection::const_iterator pos =
m_signals.find(current_signal);
177 collection::const_iterator end =
m_signals.end();
191 bool &should_notify)
const {
192 collection::const_iterator pos =
m_signals.find(signo);
196 const Signal &signal = pos->second;
198 should_stop = signal.
m_stop;
205 collection::const_iterator pos =
m_signals.find(signo);
207 return pos->second.m_suppress;
212 collection::iterator pos =
m_signals.find(signo);
214 pos->second.m_suppress = value;
229 collection::const_iterator pos =
m_signals.find(signo);
231 return pos->second.m_stop;
236 collection::iterator pos =
m_signals.find(signo);
238 pos->second.m_stop = value;
253 collection::const_iterator pos =
m_signals.find(signo);
255 return pos->second.m_notify;
260 collection::iterator pos =
m_signals.find(signo);
262 pos->second.m_notify = value;
279 if (index < 0 ||
m_signals.size() <=
static_cast<size_t>(index))
282 std::advance(it, index);
290 std::optional<bool> should_stop,
291 std::optional<bool> should_notify) {
292 std::vector<int32_t> result;
297 bool signal_suppress =
false;
298 bool signal_stop =
false;
299 bool signal_notify =
false;
300 GetSignalInfo(signo, signal_suppress, signal_stop, signal_notify);
304 if (should_suppress && signal_suppress != *should_suppress)
307 if (should_stop && signal_stop != *should_stop)
310 if (should_notify && signal_notify != *should_notify)
313 result.push_back(signo);
320 collection::iterator pos =
m_signals.find(signo);
322 pos->second.m_hit_count += 1;
326 json::Array json_signals;
328 if (pair.second.m_hit_count > 0)
329 json_signals.emplace_back(json::Object{
330 { pair.second.m_name.GetCString(), pair.second.m_hit_count }
333 return std::move(json_signals);
337 bool reset_suppress) {
347 bool reset_notify,
bool reset_suppress) {
351 (*elem).second.Reset(reset_stop, reset_notify, reset_suppress);
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
int32_t GetSignalNumberFromName(const char *name) const
static lldb::UnixSignalsSP CreateForHost()
const char * GetSignalInfo(int32_t signo, bool &should_suppress, bool &should_stop, bool &should_notify) const
ConstString GetShortName(ConstString name) const
int32_t GetSignalAtIndex(int32_t index) const
bool GetShouldNotify(int32_t signo) const
std::vector< int32_t > GetFilteredSignals(std::optional< bool > should_suppress, std::optional< bool > should_stop, std::optional< bool > should_notify)
void IncrementSignalHitCount(int signo)
Track how many times signals are hit as stop reasons.
bool SetShouldStop(int32_t signo, bool value)
void RemoveSignal(int signo)
bool SetShouldSuppress(int32_t signo, bool value)
int32_t GetFirstSignalNumber() const
static lldb::UnixSignalsSP Create(const ArchSpec &arch)
int32_t GetNumSignals() const
bool ResetSignal(int32_t signo, bool reset_stop=true, bool reset_notify=true, bool reset_suppress=true)
bool SignalIsValid(int32_t signo) const
llvm::json::Value GetHitCountStatistics() const
Get the hit count statistics for signals.
void AddSignal(int signo, const char *name, bool default_suppress, bool default_stop, bool default_notify, const char *description, const char *alias=nullptr)
int32_t GetNextSignalNumber(int32_t current_signal) const
bool SetShouldNotify(int32_t signo, bool value)
const char * GetSignalAsCString(int32_t signo) const
bool GetShouldSuppress(int32_t signo) const
bool GetShouldStop(int32_t signo) const
uint64_t GetVersion() const
#define LLDB_INVALID_SIGNAL_NUMBER
A class that represents a running process on the host machine.
Signal(const char *name, bool default_suppress, bool default_stop, bool default_notify, const char *description, const char *alias)
std::string m_description
void Reset(bool reset_stop, bool reset_notify, bool reset_suppress)