mirror of
https://github.com/intel/llvm.git
synced 2026-01-12 18:27:07 +08:00
[lldb] Show signal number description (#164176)
show information about the signal when the user presses `process handle
<unix-signal>` i.e
```sh
(lldb) process handle SIGWINCH
NAME PASS STOP NOTIFY DESCRIPTION
=========== ===== ===== ====== ===================
SIGWINCH true false false window size changes
```
Wanted to use the existing `GetSignalDescription` but it is expected
behaviour to return the signal name if no signal code is passed. It is
used in stop info.
65c895dfe0/lldb/source/Target/StopInfo.cpp (L1192-L1195)
This commit is contained in:
@@ -31,6 +31,8 @@ public:
|
||||
|
||||
llvm::StringRef GetSignalAsStringRef(int32_t signo) const;
|
||||
|
||||
llvm::StringRef GetSignalNumberDescription(int32_t signo) const;
|
||||
|
||||
std::string
|
||||
GetSignalDescription(int32_t signo,
|
||||
std::optional<int32_t> code = std::nullopt,
|
||||
|
||||
@@ -1603,8 +1603,8 @@ public:
|
||||
Options *GetOptions() override { return &m_options; }
|
||||
|
||||
void PrintSignalHeader(Stream &str) {
|
||||
str.Printf("NAME PASS STOP NOTIFY\n");
|
||||
str.Printf("=========== ===== ===== ======\n");
|
||||
str.Printf("NAME PASS STOP NOTIFY DESCRIPTION\n");
|
||||
str.Printf("=========== ===== ===== ====== ===================\n");
|
||||
}
|
||||
|
||||
void PrintSignal(Stream &str, int32_t signo, llvm::StringRef sig_name,
|
||||
@@ -1615,9 +1615,16 @@ public:
|
||||
|
||||
str.Format("{0, -11} ", sig_name);
|
||||
if (signals_sp->GetSignalInfo(signo, suppress, stop, notify)) {
|
||||
bool pass = !suppress;
|
||||
const bool pass = !suppress;
|
||||
str.Printf("%s %s %s", (pass ? "true " : "false"),
|
||||
(stop ? "true " : "false"), (notify ? "true " : "false"));
|
||||
|
||||
const llvm::StringRef sig_description =
|
||||
signals_sp->GetSignalNumberDescription(signo);
|
||||
if (!sig_description.empty()) {
|
||||
str.PutCString(" ");
|
||||
str.PutCString(sig_description);
|
||||
}
|
||||
}
|
||||
str.Printf("\n");
|
||||
}
|
||||
|
||||
@@ -137,6 +137,13 @@ llvm::StringRef UnixSignals::GetSignalAsStringRef(int32_t signo) const {
|
||||
return pos->second.m_name;
|
||||
}
|
||||
|
||||
llvm::StringRef UnixSignals::GetSignalNumberDescription(int32_t signo) const {
|
||||
const auto pos = m_signals.find(signo);
|
||||
if (pos == m_signals.end())
|
||||
return {};
|
||||
return pos->second.m_description;
|
||||
}
|
||||
|
||||
std::string UnixSignals::GetSignalDescription(
|
||||
int32_t signo, std::optional<int32_t> code,
|
||||
std::optional<lldb::addr_t> addr, std::optional<lldb::addr_t> lower,
|
||||
|
||||
@@ -148,6 +148,18 @@ TEST(UnixSignalsTest, GetAsString) {
|
||||
signals.GetSignalDescription(16, 3, 0x1233, 0x1234, 0x5678));
|
||||
}
|
||||
|
||||
TEST(UnixSignalsTest, GetNumberDescription) {
|
||||
TestSignals signals;
|
||||
|
||||
ASSERT_EQ("DESC2", signals.GetSignalNumberDescription(2));
|
||||
ASSERT_EQ("DESC4", signals.GetSignalNumberDescription(4));
|
||||
ASSERT_EQ("DESC8", signals.GetSignalNumberDescription(8));
|
||||
ASSERT_EQ("DESC16", signals.GetSignalNumberDescription(16));
|
||||
|
||||
// Unknown signal number.
|
||||
ASSERT_EQ("", signals.GetSignalNumberDescription(100));
|
||||
}
|
||||
|
||||
TEST(UnixSignalsTest, VersionChange) {
|
||||
TestSignals signals;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user