[Lldb-commits] [lldb] r310591 - Report inferior signals as signals, not exceptions, on FreeBSD

Ed Maste via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 10 06:47:17 PDT 2017


Author: emaste
Date: Thu Aug 10 06:47:17 2017
New Revision: 310591

URL: http://llvm.org/viewvc/llvm-project?rev=310591&view=rev
Log:
Report inferior signals as signals, not exceptions, on FreeBSD

This is the FreeBSD equivalent of r238549.

This serves 2 purposes:

* LLDB should handle inferior process signals SIGSEGV/SIGILL/SIGBUS/
  SIGFPE the way it is suppose to be handled. Prior to this fix these
  signals will neither create a coredump, nor exit from the debugger
  or work for signal handling scenario.
* eInvalidCrashReason need not report "unknown crash reason" if we have
  a valid si_signo

llvm.org/pr23699

Patch by Karnajit Wangkhem

Differential Revision:	https://reviews.llvm.org/D35223

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py
    lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
    lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
    lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
    lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py?rev=310591&r1=310590&r2=310591&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py Thu Aug 10 06:47:17 2017
@@ -17,9 +17,6 @@ class CrashingInferiorTestCase(TestBase)
     mydir = TestBase.compute_mydir(__file__)
 
     @expectedFailureAll(
-        oslist=['freebsd'],
-        bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal")
-    @expectedFailureAll(
         oslist=["windows"],
         bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")
     def test_inferior_crashing(self):
@@ -60,7 +57,6 @@ class CrashingInferiorTestCase(TestBase)
         self.build()
         self.inferior_crashing_step()
 
-    @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24939')
     @expectedFailureAll(
         oslist=["windows"],
         bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")
@@ -76,6 +72,7 @@ class CrashingInferiorTestCase(TestBase)
     # Inferior exits after stepping after a segfault. This is working as
     # intended IMHO.
     @skipIfLinux
+    @skipIfFreeBSD
     def test_inferior_crashing_expr_step_and_expr(self):
         """Test that lldb expressions work before and after stepping after a crash."""
         self.build()
@@ -110,7 +107,7 @@ class CrashingInferiorTestCase(TestBase)
         # The exact stop reason depends on the platform
         if self.platformIsDarwin():
             stop_reason = 'stop reason = EXC_BAD_ACCESS'
-        elif self.getPlatform() == "linux":
+        elif self.getPlatform() == "linux" or self.getPlatform() == "freebsd":
             stop_reason = 'stop reason = signal SIGSEGV'
         else:
             stop_reason = 'stop reason = invalid address'

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py?rev=310591&r1=310590&r2=310591&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py Thu Aug 10 06:47:17 2017
@@ -16,9 +16,6 @@ class CrashingRecursiveInferiorTestCase(
 
     mydir = TestBase.compute_mydir(__file__)
 
-    @expectedFailureAll(
-        oslist=['freebsd'],
-        bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal")
     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
     def test_recursive_inferior_crashing(self):
         """Test that lldb reliably catches the inferior crashing (command)."""
@@ -50,7 +47,6 @@ class CrashingRecursiveInferiorTestCase(
         self.build()
         self.recursive_inferior_crashing_step()
 
-    @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24939')
     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
     @skipIfTargetAndroid()  # debuggerd interferes with this test on Android
     def test_recursive_inferior_crashing_step_after_break(self):
@@ -61,6 +57,7 @@ class CrashingRecursiveInferiorTestCase(
     # Inferior exits after stepping after a segfault. This is working as
     # intended IMHO.
     @skipIfLinux
+    @skipIfFreeBSD
     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
     def test_recursive_inferior_crashing_expr_step_and_expr(self):
         """Test that lldb expressions work before and after stepping after a crash."""
@@ -94,7 +91,7 @@ class CrashingRecursiveInferiorTestCase(
         # The exact stop reason depends on the platform
         if self.platformIsDarwin():
             stop_reason = 'stop reason = EXC_BAD_ACCESS'
-        elif self.getPlatform() == "linux":
+        elif self.getPlatform() == "linux" or self.getPlatform() == "freebsd":
             stop_reason = 'stop reason = signal SIGSEGV'
         else:
             stop_reason = 'stop reason = invalid address'

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py?rev=310591&r1=310590&r2=310591&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py Thu Aug 10 06:47:17 2017
@@ -18,9 +18,6 @@ class HandleSegvTestCase(TestBase):
 
     @skipIfWindows  # signals do not exist on Windows
     @skipIfDarwin
-    @expectedFailureAll(
-        oslist=['freebsd'],
-        bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal")
     def test_inferior_handle_sigsegv(self):
         self.build()
         exe = os.path.join(os.getcwd(), "a.out")

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp?rev=310591&r1=310590&r2=310591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp Thu Aug 10 06:47:17 2017
@@ -375,6 +375,7 @@ void FreeBSDThread::Notify(const Process
     LimboNotify(message);
     break;
 
+  case ProcessMessage::eCrashMessage:
   case ProcessMessage::eSignalMessage:
     SignalNotify(message);
     break;
@@ -395,10 +396,6 @@ void FreeBSDThread::Notify(const Process
     WatchNotify(message);
     break;
 
-  case ProcessMessage::eCrashMessage:
-    CrashNotify(message);
-    break;
-
   case ProcessMessage::eExecMessage:
     ExecNotify(message);
     break;
@@ -577,7 +574,14 @@ void FreeBSDThread::LimboNotify(const Pr
 
 void FreeBSDThread::SignalNotify(const ProcessMessage &message) {
   int signo = message.GetSignal();
-  SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo));
+  if (message.GetKind() == ProcessMessage::eCrashMessage) {
+    std::string stop_description = GetCrashReasonString(
+        message.GetCrashReason(), message.GetFaultAddress());
+    SetStopInfo(StopInfo::CreateStopReasonWithSignal(
+        *this, signo, stop_description.c_str()));
+  } else {
+    SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo));
+  }
 }
 
 void FreeBSDThread::SignalDeliveredNotify(const ProcessMessage &message) {
@@ -585,21 +589,6 @@ void FreeBSDThread::SignalDeliveredNotif
   SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, signo));
 }
 
-void FreeBSDThread::CrashNotify(const ProcessMessage &message) {
-  // FIXME: Update stop reason as per bugzilla 14598
-  int signo = message.GetSignal();
-
-  assert(message.GetKind() == ProcessMessage::eCrashMessage);
-
-  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
-  if (log)
-    log->Printf("FreeBSDThread::%s () signo = %i, reason = '%s'", __FUNCTION__,
-                signo, message.PrintCrashReason());
-
-  SetStopInfo(lldb::StopInfoSP(new POSIXCrashStopInfo(
-      *this, signo, message.GetCrashReason(), message.GetFaultAddress())));
-}
-
 unsigned FreeBSDThread::GetRegisterIndexFromOffset(unsigned offset) {
   unsigned reg = LLDB_INVALID_REGNUM;
   ArchSpec arch = HostInfo::GetArchitecture();

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp?rev=310591&r1=310590&r2=310591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp Thu Aug 10 06:47:17 2017
@@ -28,22 +28,6 @@ bool POSIXLimboStopInfo::ShouldStop(Even
 bool POSIXLimboStopInfo::ShouldNotify(Event *event_ptr) { return false; }
 
 //===----------------------------------------------------------------------===//
-// POSIXCrashStopInfo
-
-POSIXCrashStopInfo::POSIXCrashStopInfo(FreeBSDThread &thread, uint32_t status,
-                                       CrashReason reason,
-                                       lldb::addr_t fault_addr)
-    : POSIXStopInfo(thread, status) {
-  m_description = ::GetCrashReasonString(reason, fault_addr);
-}
-
-POSIXCrashStopInfo::~POSIXCrashStopInfo() {}
-
-lldb::StopReason POSIXCrashStopInfo::GetStopReason() const {
-  return lldb::eStopReasonException;
-}
-
-//===----------------------------------------------------------------------===//
 // POSIXNewThreadStopInfo
 
 POSIXNewThreadStopInfo::~POSIXNewThreadStopInfo() {}

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.h?rev=310591&r1=310590&r2=310591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.h (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.h Thu Aug 10 06:47:17 2017
@@ -45,19 +45,6 @@ public:
 };
 
 //===----------------------------------------------------------------------===//
-/// @class POSIXCrashStopInfo
-/// @brief Represents the stop state of process that is ready to crash.
-///
-class POSIXCrashStopInfo : public POSIXStopInfo {
-public:
-  POSIXCrashStopInfo(FreeBSDThread &thread, uint32_t status, CrashReason reason,
-                     lldb::addr_t fault_addr);
-  ~POSIXCrashStopInfo();
-
-  lldb::StopReason GetStopReason() const;
-};
-
-//===----------------------------------------------------------------------===//
 /// @class POSIXNewThreadStopInfo
 /// @brief Represents the stop state of process when a new thread is spawned.
 ///

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp?rev=310591&r1=310590&r2=310591&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Thu Aug 10 06:47:17 2017
@@ -1192,7 +1192,9 @@ ProcessMessage ProcessMonitor::MonitorSi
   case SIGBUS:
     lldb::addr_t fault_addr = reinterpret_cast<lldb::addr_t>(info->si_addr);
     const auto reason = GetCrashReason(*info);
-    return ProcessMessage::Crash(tid, reason, signo, fault_addr);
+    if (reason != CrashReason::eInvalidCrashReason) {
+      return ProcessMessage::Crash(tid, reason, signo, fault_addr);
+    } // else; Use atleast si_signo info for other si_code
   }
 
   // Everything else is "normal" and does not require any special action on




More information about the lldb-commits mailing list