This revision was automatically updated to reflect the committed changes.
Closed by commit rGebff12d675aa: [lldb][NFCI] Change return type of 
UnixSignals::GetSignalInfo (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158457/new/

https://reviews.llvm.org/D158457

Files:
  lldb/include/lldb/Target/UnixSignals.h
  lldb/source/Target/UnixSignals.cpp
  lldb/unittests/Signals/UnixSignalsTest.cpp


Index: lldb/unittests/Signals/UnixSignalsTest.cpp
===================================================================
--- lldb/unittests/Signals/UnixSignalsTest.cpp
+++ lldb/unittests/Signals/UnixSignalsTest.cpp
@@ -84,9 +84,9 @@
 
   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 @@
   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) {
Index: lldb/source/Target/UnixSignals.cpp
===================================================================
--- lldb/source/Target/UnixSignals.cpp
+++ lldb/source/Target/UnixSignals.cpp
@@ -237,19 +237,17 @@
   }
 }
 
-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 {
Index: lldb/include/lldb/Target/UnixSignals.h
===================================================================
--- lldb/include/lldb/Target/UnixSignals.h
+++ lldb/include/lldb/Target/UnixSignals.h
@@ -43,8 +43,26 @@
 
   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;
 


Index: lldb/unittests/Signals/UnixSignalsTest.cpp
===================================================================
--- lldb/unittests/Signals/UnixSignalsTest.cpp
+++ lldb/unittests/Signals/UnixSignalsTest.cpp
@@ -84,9 +84,9 @@
 
   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 @@
   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) {
Index: lldb/source/Target/UnixSignals.cpp
===================================================================
--- lldb/source/Target/UnixSignals.cpp
+++ lldb/source/Target/UnixSignals.cpp
@@ -237,19 +237,17 @@
   }
 }
 
-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 {
Index: lldb/include/lldb/Target/UnixSignals.h
===================================================================
--- lldb/include/lldb/Target/UnixSignals.h
+++ lldb/include/lldb/Target/UnixSignals.h
@@ -43,8 +43,26 @@
 
   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;
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to