22 bool default_stop,
bool default_notify,
23 llvm::StringRef description, llvm::StringRef alias)
24 : m_name(name), m_alias(alias), m_description(description),
25 m_suppress(default_suppress), m_stop(default_stop),
26 m_notify(default_notify), m_default_suppress(default_suppress),
27 m_default_stop(default_stop), m_default_notify(default_notify) {}
31 switch (triple.getOS()) {
32 case llvm::Triple::Linux:
33 return std::make_shared<LinuxSignals>();
34 case llvm::Triple::FreeBSD:
35 case llvm::Triple::OpenBSD:
36 return std::make_shared<FreeBSDSignals>();
37 case llvm::Triple::NetBSD:
38 return std::make_shared<NetBSDSignals>();
40 return std::make_shared<UnixSignals>();
46 Create(HostInfo::GetArchitecture());
47 return s_unix_signals_sp;
69 AddSignal(1,
"SIGHUP",
false,
true,
true,
"hangup");
70 AddSignal(2,
"SIGINT",
true,
true,
true,
"interrupt");
71 AddSignal(3,
"SIGQUIT",
false,
true,
true,
"quit");
72 AddSignal(4,
"SIGILL",
false,
true,
true,
"illegal instruction");
73 AddSignal(5,
"SIGTRAP",
true,
true,
true,
"trace trap (not reset when caught)");
74 AddSignal(6,
"SIGABRT",
false,
true,
true,
"abort()");
75 AddSignal(7,
"SIGEMT",
false,
true,
true,
"pollable event");
76 AddSignal(8,
"SIGFPE",
false,
true,
true,
"floating point exception");
77 AddSignal(9,
"SIGKILL",
false,
true,
true,
"kill");
78 AddSignal(10,
"SIGBUS",
false,
true,
true,
"bus error");
79 AddSignal(11,
"SIGSEGV",
false,
true,
true,
"segmentation violation");
80 AddSignal(12,
"SIGSYS",
false,
true,
true,
"bad argument to system call");
81 AddSignal(13,
"SIGPIPE",
false,
false,
false,
"write on a pipe with no one to read it");
82 AddSignal(14,
"SIGALRM",
false,
false,
false,
"alarm clock");
83 AddSignal(15,
"SIGTERM",
false,
true,
true,
"software termination signal from kill");
84 AddSignal(16,
"SIGURG",
false,
false,
false,
"urgent condition on IO channel");
85 AddSignal(17,
"SIGSTOP",
true,
true,
true,
"sendable stop signal not from tty");
86 AddSignal(18,
"SIGTSTP",
false,
true,
true,
"stop signal from tty");
87 AddSignal(19,
"SIGCONT",
false,
false,
true,
"continue a stopped process");
88 AddSignal(20,
"SIGCHLD",
false,
false,
false,
"to parent on child stop or exit");
89 AddSignal(21,
"SIGTTIN",
false,
true,
true,
"to readers process group upon background tty read");
90 AddSignal(22,
"SIGTTOU",
false,
true,
true,
"to readers process group upon background tty write");
91 AddSignal(23,
"SIGIO",
false,
false,
false,
"input/output possible signal");
92 AddSignal(24,
"SIGXCPU",
false,
true,
true,
"exceeded CPU time limit");
93 AddSignal(25,
"SIGXFSZ",
false,
true,
true,
"exceeded file size limit");
94 AddSignal(26,
"SIGVTALRM",
false,
false,
false,
"virtual time alarm");
95 AddSignal(27,
"SIGPROF",
false,
false,
false,
"profiling time alarm");
96 AddSignal(28,
"SIGWINCH",
false,
false,
false,
"window size changes");
97 AddSignal(29,
"SIGINFO",
false,
true,
true,
"information request");
98 AddSignal(30,
"SIGUSR1",
false,
true,
true,
"user defined signal 1");
99 AddSignal(31,
"SIGUSR2",
false,
true,
true,
"user defined signal 2");
104 bool default_suppress,
bool default_stop,
105 bool default_notify, llvm::StringRef description,
106 llvm::StringRef alias) {
107 Signal new_signal(name, default_suppress, default_stop, default_notify,
109 m_signals.insert(std::make_pair(signo, new_signal));
114 const llvm::StringLiteral description,
116 collection::iterator signal =
m_signals.find(signo);
118 "Tried to add code to signal that does not exist.");
119 signal->second.m_codes.insert(
120 std::pair{code,
SignalCode{description, print_option}});
125 collection::iterator pos =
m_signals.find(signo);
135 return pos->second.m_name;
140 std::optional<lldb::addr_t> addr,
141 std::optional<lldb::addr_t> lower,
142 std::optional<lldb::addr_t> upper)
const {
145 collection::const_iterator pos =
m_signals.find(signo);
147 str = pos->second.m_name.str();
150 std::map<int32_t, SignalCode>::const_iterator cpos =
151 pos->second.m_codes.find(*code);
152 if (cpos != pos->second.m_codes.end()) {
158 std::stringstream strm;
164 strm <<
" (fault address: 0x" << std::hex << *addr <<
")";
167 if (lower && upper && addr) {
168 if ((
unsigned long)(*addr) < *lower)
169 strm <<
"lower bound violation ";
171 strm <<
"upper bound violation ";
173 strm <<
"(fault address: 0x" << std::hex << *addr;
174 strm <<
", lower bound: 0x" << std::hex << *lower;
175 strm <<
", upper bound: 0x" << std::hex << *upper;
195 return name.substr(3);
199 llvm::StringRef name_ref(name);
201 collection::const_iterator pos, end =
m_signals.end();
202 for (pos =
m_signals.begin(); pos != end; pos++) {
203 if ((name_ref == pos->second.m_name) || (name_ref == pos->second.m_alias) ||
210 if (llvm::to_integer(name, signo))
223 collection::const_iterator pos =
m_signals.find(current_signal);
224 collection::const_iterator end =
m_signals.end();
237 bool &should_stop,
bool &should_notify)
const {
242 const Signal &signal = pos->second;
244 should_stop = signal.
m_stop;
250 collection::const_iterator pos =
m_signals.find(signo);
252 return pos->second.m_suppress;
257 collection::iterator pos =
m_signals.find(signo);
259 pos->second.m_suppress = value;
274 collection::const_iterator pos =
m_signals.find(signo);
276 return pos->second.m_stop;
281 collection::iterator pos =
m_signals.find(signo);
283 pos->second.m_stop = value;
298 collection::const_iterator pos =
m_signals.find(signo);
300 return pos->second.m_notify;
305 collection::iterator pos =
m_signals.find(signo);
307 pos->second.m_notify = value;
324 if (index < 0 ||
m_signals.size() <=
static_cast<size_t>(index))
327 std::advance(it, index);
335 std::optional<bool> should_stop,
336 std::optional<bool> should_notify) {
337 std::vector<int32_t> result;
342 bool signal_suppress =
false;
343 bool signal_stop =
false;
344 bool signal_notify =
false;
345 GetSignalInfo(signo, signal_suppress, signal_stop, signal_notify);
349 if (should_suppress && signal_suppress != *should_suppress)
352 if (should_stop && signal_stop != *should_stop)
355 if (should_notify && signal_notify != *should_notify)
358 result.push_back(signo);
365 collection::iterator pos =
m_signals.find(signo);
367 pos->second.m_hit_count += 1;
371 json::Array json_signals;
373 if (pair.second.m_hit_count > 0)
374 json_signals.emplace_back(
375 json::Object{{pair.second.m_name, pair.second.m_hit_count}});
377 return std::move(json_signals);
381 bool reset_suppress) {
391 bool reset_notify,
bool reset_suppress) {
395 (*elem).second.Reset(reset_stop, reset_notify, reset_suppress);
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
void AddSignalCode(int signo, int code, const llvm::StringLiteral description, SignalCodePrintOption print_option=SignalCodePrintOption::None)
llvm::StringRef GetShortName(llvm::StringRef name) const
int32_t GetSignalNumberFromName(const char *name) const
static lldb::UnixSignalsSP CreateForHost()
bool GetSignalInfo(int32_t signo, bool &should_suppress, bool &should_stop, bool &should_notify) const
Gets the information for a particular signal.
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 AddSignal(int signo, llvm::StringRef name, bool default_suppress, bool default_stop, bool default_notify, llvm::StringRef description, llvm::StringRef alias=llvm::StringRef())
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.
int32_t GetNextSignalNumber(int32_t current_signal) const
bool SetShouldNotify(int32_t signo, bool value)
bool GetShouldSuppress(int32_t signo) const
llvm::StringRef GetSignalAsStringRef(int32_t signo) const
bool GetShouldStop(int32_t signo) const
std::string GetSignalDescription(int32_t signo, std::optional< int32_t > code=std::nullopt, std::optional< lldb::addr_t > addr=std::nullopt, std::optional< lldb::addr_t > lower=std::nullopt, std::optional< lldb::addr_t > upper=std::nullopt) const
uint64_t GetVersion() const
#define LLDB_INVALID_SIGNAL_NUMBER
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
const SignalCodePrintOption m_print_option
const llvm::StringLiteral m_description
Signal(llvm::StringRef name, bool default_suppress, bool default_stop, bool default_notify, llvm::StringRef description, llvm::StringRef alias)
void Reset(bool reset_stop, bool reset_notify, bool reset_suppress)