[lldb][NFCI] Change return type of UnixSignals::GetSignalInfo

There's no reason for GetSignalInfo to return the signal name. All users
of this method only use the return value to determine if the method
succeeded in filling in the output parameters, so let's explicitly make
it a bool instead of a pointer.

Differential Revision: https://reviews.llvm.org/D158457
This commit is contained in:
Alex Langford 2023-08-21 14:29:24 -07:00
parent 8a20612467
commit ebff12d675
3 changed files with 32 additions and 17 deletions

View File

@ -43,8 +43,26 @@ public:
int32_t GetSignalNumberFromName(const char *name) const;
const char *GetSignalInfo(int32_t signo, bool &should_suppress,
bool &should_stop, bool &should_notify) const;
/// Gets the information for a particular signal
///
/// GetSignalInfo takes a signal number and populates 3 out parameters
/// describing how lldb should react when a particular signal is received in
/// the inferior.
///
/// \param[in] signo
/// The signal number to get information about.
/// \param[out] should_suppress
/// Should we suppress this signal?
/// \param[out] should_stop
/// Should we stop if this signal is received?
/// \param[out] should_notify
/// Should we notify the user if this signal is received?
///
/// \return
/// Returns a boolean value. Returns true if the out parameters were
/// successfully populated, false otherwise.
bool GetSignalInfo(int32_t signo, bool &should_suppress, bool &should_stop,
bool &should_notify) const;
bool GetShouldSuppress(int32_t signo) const;

View File

@ -237,19 +237,17 @@ int32_t UnixSignals::GetNextSignalNumber(int32_t current_signal) const {
}
}
const char *UnixSignals::GetSignalInfo(int32_t signo, bool &should_suppress,
bool &should_stop,
bool &should_notify) const {
collection::const_iterator pos = m_signals.find(signo);
bool UnixSignals::GetSignalInfo(int32_t signo, bool &should_suppress,
bool &should_stop, bool &should_notify) const {
const auto pos = m_signals.find(signo);
if (pos == m_signals.end())
return nullptr;
else {
const Signal &signal = pos->second;
should_suppress = signal.m_suppress;
should_stop = signal.m_stop;
should_notify = signal.m_notify;
return signal.m_name.AsCString("");
}
return false;
const Signal &signal = pos->second;
should_suppress = signal.m_suppress;
should_stop = signal.m_stop;
should_notify = signal.m_notify;
return true;
}
bool UnixSignals::GetShouldSuppress(int signo) const {

View File

@ -84,9 +84,9 @@ TEST(UnixSignalsTest, GetInfo) {
bool should_suppress = false, should_stop = false, should_notify = false;
int32_t signo = 4;
llvm::StringRef name =
bool success =
signals.GetSignalInfo(signo, should_suppress, should_stop, should_notify);
EXPECT_EQ("SIG4", name);
ASSERT_TRUE(success);
EXPECT_EQ(true, should_suppress);
EXPECT_EQ(false, should_stop);
EXPECT_EQ(true, should_notify);
@ -94,7 +94,6 @@ TEST(UnixSignalsTest, GetInfo) {
EXPECT_EQ(true, signals.GetShouldSuppress(signo));
EXPECT_EQ(false, signals.GetShouldStop(signo));
EXPECT_EQ(true, signals.GetShouldNotify(signo));
EXPECT_EQ(name, signals.GetSignalAsStringRef(signo));
}
TEST(UnixSignalsTest, GetAsStringRef) {