forked from OSchip/llvm-project
Add output of fault address on an address related crash (ie. segfault).
llvm-svn: 183701
This commit is contained in:
parent
b07cebffb2
commit
b96a126b5b
|
@ -56,7 +56,7 @@ POSIXCrashStopInfo::GetStopReason() const
|
|||
const char *
|
||||
POSIXCrashStopInfo::GetDescription()
|
||||
{
|
||||
return ProcessMessage::GetCrashReasonString(m_crash_reason);
|
||||
return ProcessMessage::GetCrashReasonString(m_crash_reason, m_fault_addr);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -237,7 +237,8 @@ POSIXThread::Notify(const ProcessMessage &message)
|
|||
{
|
||||
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 ProcessMessage &message)
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,25 @@
|
|||
|
||||
#include "ProcessMessage.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
const char *
|
||||
ProcessMessage::GetCrashReasonString(CrashReason reason)
|
||||
namespace {
|
||||
|
||||
inline void AppendFaultAddr(std::string& str, lldb::addr_t addr)
|
||||
{
|
||||
const char *str = NULL;
|
||||
std::stringstream ss;
|
||||
ss << " (fault address: 0x" << std::hex << addr << ")";
|
||||
str += ss.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const char *
|
||||
ProcessMessage::GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr)
|
||||
{
|
||||
static std::string str;
|
||||
|
||||
switch (reason)
|
||||
{
|
||||
|
@ -24,9 +37,11 @@ ProcessMessage::GetCrashReasonString(CrashReason reason)
|
|||
|
||||
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(CrashReason reason)
|
|||
break;
|
||||
}
|
||||
|
||||
return str;
|
||||
return str.c_str();
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
|
@ -164,7 +164,7 @@ public:
|
|||
}
|
||||
|
||||
static const char *
|
||||
GetCrashReasonString(CrashReason reason);
|
||||
GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr);
|
||||
|
||||
const char *
|
||||
PrintCrashReason() const;
|
||||
|
|
Loading…
Reference in New Issue