23 bool default_stop,
bool default_notify,
24 llvm::StringRef description, llvm::StringRef alias)
25 : m_name(name), m_alias(alias), m_description(description),
26 m_suppress(default_suppress), m_stop(default_stop),
27 m_notify(default_notify), m_default_suppress(default_suppress),
28 m_default_stop(default_stop), m_default_notify(default_notify) {}
32 switch (triple.getOS()) {
33 case llvm::Triple::Linux:
34 return std::make_shared<LinuxSignals>();
35 case llvm::Triple::FreeBSD:
36 return std::make_shared<FreeBSDSignals>();
37 case llvm::Triple::NetBSD:
38 return std::make_shared<NetBSDSignals>();
39 case llvm::Triple::OpenBSD:
40 return std::make_shared<OpenBSDSignals>();
42 return std::make_shared<UnixSignals>();
48 Create(HostInfo::GetArchitecture());
49 return s_unix_signals_sp;
71 AddSignal(1,
"SIGHUP",
false,
true,
true,
"hangup");
72 AddSignal(2,
"SIGINT",
true,
true,
true,
"interrupt");
73 AddSignal(3,
"SIGQUIT",
false,
true,
true,
"quit");
74 AddSignal(4,
"SIGILL",
false,
true,
true,
"illegal instruction");
75 AddSignal(5,
"SIGTRAP",
true,
true,
true,
"trace trap (not reset when caught)");
76 AddSignal(6,
"SIGABRT",
false,
true,
true,
"abort()");
77 AddSignal(7,
"SIGEMT",
false,
true,
true,
"pollable event");
78 AddSignal(8,
"SIGFPE",
false,
true,
true,
"floating point exception");
79 AddSignal(9,
"SIGKILL",
false,
true,
true,
"kill");
80 AddSignal(10,
"SIGBUS",
false,
true,
true,
"bus error");
81 AddSignal(11,
"SIGSEGV",
false,
true,
true,
"segmentation violation");
82 AddSignal(12,
"SIGSYS",
false,
true,
true,
"bad argument to system call");
83 AddSignal(13,
"SIGPIPE",
false,
false,
false,
"write on a pipe with no one to read it");
84 AddSignal(14,
"SIGALRM",
false,
false,
false,
"alarm clock");
85 AddSignal(15,
"SIGTERM",
false,
true,
true,
"software termination signal from kill");
86 AddSignal(16,
"SIGURG",
false,
false,
false,
"urgent condition on IO channel");
87 AddSignal(17,
"SIGSTOP",
true,
true,
true,
"sendable stop signal not from tty");
88 AddSignal(18,
"SIGTSTP",
false,
true,
true,
"stop signal from tty");
89 AddSignal(19,
"SIGCONT",
false,
false,
true,
"continue a stopped process");
90 AddSignal(20,
"SIGCHLD",
false,
false,
false,
"to parent on child stop or exit");
91 AddSignal(21,
"SIGTTIN",
false,
true,
true,
"to readers process group upon background tty read");
92 AddSignal(22,
"SIGTTOU",
false,
true,
true,
"to readers process group upon background tty write");
93 AddSignal(23,
"SIGIO",
false,
false,
false,
"input/output possible signal");
94 AddSignal(24,
"SIGXCPU",
false,
true,
true,
"exceeded CPU time limit");
95 AddSignal(25,
"SIGXFSZ",
false,
true,
true,
"exceeded file size limit");
96 AddSignal(26,
"SIGVTALRM",
false,
false,
false,
"virtual time alarm");
97 AddSignal(27,
"SIGPROF",
false,
false,
false,
"profiling time alarm");
98 AddSignal(28,
"SIGWINCH",
false,
false,
false,
"window size changes");
99 AddSignal(29,
"SIGINFO",
false,
true,
true,
"information request");
100 AddSignal(30,
"SIGUSR1",
false,
true,
true,
"user defined signal 1");
101 AddSignal(31,
"SIGUSR2",
false,
true,
true,
"user defined signal 2");
106 bool default_suppress,
bool default_stop,
107 bool default_notify, llvm::StringRef description,
108 llvm::StringRef alias) {
109 Signal new_signal(name, default_suppress, default_stop, default_notify,
111 m_signals.insert(std::make_pair(signo, new_signal));
116 const llvm::StringLiteral description,
118 collection::iterator signal =
m_signals.find(signo);
120 "Tried to add code to signal that does not exist.");
121 signal->second.m_codes.insert(
122 std::pair{code,
SignalCode{description, print_option}});
127 collection::iterator pos =
m_signals.find(signo);
137 return pos->second.m_name;
142 std::optional<lldb::addr_t> addr,
143 std::optional<lldb::addr_t> lower,
144 std::optional<lldb::addr_t> upper)
const {
147 collection::const_iterator pos =
m_signals.find(signo);
149 str = pos->second.m_name.str();
152 std::map<int32_t, SignalCode>::const_iterator cpos =
153 pos->second.m_codes.find(*code);
154 if (cpos != pos->second.m_codes.end()) {
160 std::stringstream strm;
166 strm <<
" (fault address=0x" << std::hex << *addr <<
")";
169 if (lower && upper && addr) {
170 if ((
unsigned long)(*addr) < *lower)
171 strm <<
"lower bound violation ";
173 strm <<
"upper bound violation ";
175 strm <<
"(fault address=0x" << std::hex << *addr;
176 strm <<
", lower bound=0x" << std::hex << *lower;
177 strm <<
", upper bound=0x" << std::hex << *upper;
197 return name.substr(3);
201 llvm::StringRef name_ref(name);
203 collection::const_iterator pos, end =
m_signals.end();
204 for (pos =
m_signals.begin(); pos != end; pos++) {
205 if ((name_ref == pos->second.m_name) || (name_ref == pos->second.m_alias) ||
212 if (llvm::to_integer(name, signo))
225 collection::const_iterator pos =
m_signals.find(current_signal);
226 collection::const_iterator end =
m_signals.end();
239 bool &should_stop,
bool &should_notify)
const {
244 const Signal &signal = pos->second;
246 should_stop = signal.
m_stop;
252 collection::const_iterator pos =
m_signals.find(signo);
254 return pos->second.m_suppress;
259 collection::iterator pos =
m_signals.find(signo);
261 pos->second.m_suppress = value;
276 collection::const_iterator pos =
m_signals.find(signo);
278 return pos->second.m_stop;
283 collection::iterator pos =
m_signals.find(signo);
285 pos->second.m_stop = value;
300 collection::const_iterator pos =
m_signals.find(signo);
302 return pos->second.m_notify;
307 collection::iterator pos =
m_signals.find(signo);
309 pos->second.m_notify = value;
326 if (index < 0 ||
m_signals.size() <=
static_cast<size_t>(index))
329 std::advance(it, index);
337 std::optional<bool> should_stop,
338 std::optional<bool> should_notify) {
339 std::vector<int32_t> result;
344 bool signal_suppress =
false;
345 bool signal_stop =
false;
346 bool signal_notify =
false;
347 GetSignalInfo(signo, signal_suppress, signal_stop, signal_notify);
351 if (should_suppress && signal_suppress != *should_suppress)
354 if (should_stop && signal_stop != *should_stop)
357 if (should_notify && signal_notify != *should_notify)
360 result.push_back(signo);
367 collection::iterator pos =
m_signals.find(signo);
369 pos->second.m_hit_count += 1;
373 json::Array json_signals;
375 if (pair.second.m_hit_count > 0)
376 json_signals.emplace_back(
377 json::Object{{pair.second.m_name, pair.second.m_hit_count}});
379 return std::move(json_signals);
383 bool reset_suppress) {
393 bool reset_notify,
bool reset_suppress) {
397 (*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)