karnajitw created this revision.
Herald added a subscriber: emaste.
This is the freebsd equivalent of https://reviews.llvm.org/rL238549.
The fix serves 2 purpose
1. 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.
2. eInvalidCrashReason need not report "unknown crash reason" if we have a
valid si_signo
Repository:
rL LLVM
https://reviews.llvm.org/D35223
Files:
FreeBSD/FreeBSDThread.cpp
FreeBSD/POSIXStopInfo.cpp
FreeBSD/POSIXStopInfo.h
FreeBSD/ProcessMonitor.cpp
Index: FreeBSD/ProcessMonitor.cpp
===================================================================
--- FreeBSD/ProcessMonitor.cpp
+++ FreeBSD/ProcessMonitor.cpp
@@ -1204,7 +1204,9 @@
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
Index: FreeBSD/POSIXStopInfo.h
===================================================================
--- FreeBSD/POSIXStopInfo.h
+++ FreeBSD/POSIXStopInfo.h
@@ -45,19 +45,6 @@
};
//===----------------------------------------------------------------------===//
-/// @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.
///
Index: FreeBSD/POSIXStopInfo.cpp
===================================================================
--- FreeBSD/POSIXStopInfo.cpp
+++ FreeBSD/POSIXStopInfo.cpp
@@ -28,22 +28,6 @@
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() {}
Index: FreeBSD/FreeBSDThread.cpp
===================================================================
--- FreeBSD/FreeBSDThread.cpp
+++ FreeBSD/FreeBSDThread.cpp
@@ -375,6 +375,7 @@
LimboNotify(message);
break;
+ case ProcessMessage::eCrashMessage:
case ProcessMessage::eSignalMessage:
SignalNotify(message);
break;
@@ -395,10 +396,6 @@
WatchNotify(message);
break;
- case ProcessMessage::eCrashMessage:
- CrashNotify(message);
- break;
-
case ProcessMessage::eExecMessage:
ExecNotify(message);
break;
@@ -577,7 +574,15 @@
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(),
+ reinterpret_cast<uintptr_t>(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 +590,6 @@
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();
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits