[Lldb-commits] [lldb] r183701 - Add output of fault address on an address related crash (ie. segfault).
Matt Kopec
Matt.Kopec at intel.com
Mon Jun 10 15:14:47 PDT 2013
Author: mkopec
Date: Mon Jun 10 17:14:47 2013
New Revision: 183701
URL: http://llvm.org/viewvc/llvm-project?rev=183701&view=rev
Log:
Add output of fault address on an address related crash (ie. segfault).
Modified:
lldb/trunk/source/Plugins/Process/POSIX/POSIXStopInfo.cpp
lldb/trunk/source/Plugins/Process/POSIX/POSIXStopInfo.h
lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp
lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp
lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h
Modified: lldb/trunk/source/Plugins/Process/POSIX/POSIXStopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/POSIXStopInfo.cpp?rev=183701&r1=183700&r2=183701&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/POSIXStopInfo.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/POSIXStopInfo.cpp Mon Jun 10 17:14:47 2013
@@ -56,7 +56,7 @@ POSIXCrashStopInfo::GetStopReason() cons
const char *
POSIXCrashStopInfo::GetDescription()
{
- return ProcessMessage::GetCrashReasonString(m_crash_reason);
+ return ProcessMessage::GetCrashReasonString(m_crash_reason, m_fault_addr);
}
//===----------------------------------------------------------------------===//
Modified: lldb/trunk/source/Plugins/Process/POSIX/POSIXStopInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/POSIXStopInfo.h?rev=183701&r1=183700&r2=183701&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/POSIXStopInfo.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/POSIXStopInfo.h Mon Jun 10 17:14:47 2013
@@ -68,10 +68,12 @@ class POSIXCrashStopInfo
: public POSIXStopInfo
{
public:
- POSIXCrashStopInfo(POSIXThread &thread, uint32_t status,
- ProcessMessage::CrashReason reason)
+ POSIXCrashStopInfo(POSIXThread &thread, uint32_t status,
+ ProcessMessage::CrashReason reason,
+ lldb::addr_t fault_addr)
: POSIXStopInfo(thread, status),
- m_crash_reason(reason)
+ m_crash_reason(reason),
+ m_fault_addr(fault_addr)
{ }
~POSIXCrashStopInfo();
@@ -82,11 +84,9 @@ public:
const char *
GetDescription();
- ProcessMessage::CrashReason
- GetCrashReason() const;
-
private:
ProcessMessage::CrashReason m_crash_reason;
+ lldb::addr_t m_fault_addr;
};
//===----------------------------------------------------------------------===//
Modified: lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp?rev=183701&r1=183700&r2=183701&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp Mon Jun 10 17:14:47 2013
@@ -237,7 +237,8 @@ POSIXThread::Notify(const ProcessMessage
{
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
if (log)
- log->Printf ("POSIXThread::%s () message kind = '%s'", __FUNCTION__, message.PrintKind());
+ log->Printf ("POSIXThread::%s () message kind = '%s' for tid %" PRIu64,
+ __FUNCTION__, message.PrintKind(), GetID());
switch (message.GetKind())
{
@@ -467,9 +468,12 @@ POSIXThread::CrashNotify(const ProcessMe
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
if (log)
- log->Printf ("POSIXThread::%s () signo = %i, reason = '%s'", __FUNCTION__, signo, message.PrintCrashReason());
+ log->Printf ("POSIXThread::%s () signo = %i, reason = '%s'",
+ __FUNCTION__, signo, message.PrintCrashReason());
- SetStopInfo (lldb::StopInfoSP(new POSIXCrashStopInfo(*this, signo, message.GetCrashReason())));
+ SetStopInfo (lldb::StopInfoSP(new POSIXCrashStopInfo(*this, signo,
+ message.GetCrashReason(),
+ message.GetFaultAddress())));
SetResumeSignal(signo);
}
Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp?rev=183701&r1=183700&r2=183701&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp Mon Jun 10 17:14:47 2013
@@ -9,12 +9,25 @@
#include "ProcessMessage.h"
+#include <sstream>
+
using namespace lldb_private;
+namespace {
+
+inline void AppendFaultAddr(std::string& str, lldb::addr_t addr)
+{
+ std::stringstream ss;
+ ss << " (fault address: 0x" << std::hex << addr << ")";
+ str += ss.str();
+}
+
+}
+
const char *
-ProcessMessage::GetCrashReasonString(CrashReason reason)
+ProcessMessage::GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr)
{
- const char *str = NULL;
+ static std::string str;
switch (reason)
{
@@ -24,9 +37,11 @@ ProcessMessage::GetCrashReasonString(Cra
case eInvalidAddress:
str = "invalid address";
+ AppendFaultAddr(str, fault_addr);
break;
case ePrivilegedAddress:
str = "address access protected";
+ AppendFaultAddr(str, fault_addr);
break;
case eIllegalOpcode:
str = "illegal instruction";
@@ -87,7 +102,7 @@ ProcessMessage::GetCrashReasonString(Cra
break;
}
- return str;
+ return str.c_str();
}
const char *
Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h?rev=183701&r1=183700&r2=183701&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h Mon Jun 10 17:14:47 2013
@@ -164,7 +164,7 @@ public:
}
static const char *
- GetCrashReasonString(CrashReason reason);
+ GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr);
const char *
PrintCrashReason() const;
More information about the lldb-commits
mailing list