valentinagiusti updated this revision to Diff 73907. valentinagiusti added a comment.
applied clang-format https://reviews.llvm.org/D25362 Files: source/Plugins/Process/POSIX/CrashReason.cpp source/Plugins/Process/POSIX/CrashReason.h Index: source/Plugins/Process/POSIX/CrashReason.h =================================================================== --- source/Plugins/Process/POSIX/CrashReason.h +++ source/Plugins/Process/POSIX/CrashReason.h @@ -50,6 +50,7 @@ eFloatSubscriptRange }; +std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr); std::string GetCrashReasonString(CrashReason reason, const siginfo_t &info); const char *CrashReasonAsString(CrashReason reason); Index: source/Plugins/Process/POSIX/CrashReason.cpp =================================================================== --- source/Plugins/Process/POSIX/CrashReason.cpp +++ source/Plugins/Process/POSIX/CrashReason.cpp @@ -136,27 +136,42 @@ std::string GetCrashReasonString(CrashReason reason, const siginfo_t &info) { std::string str; + if (reason == CrashReason::eBoundViolation) { +// make sure that siginfo_t has the bound fields available. +#if defined(si_lower) && defined(si_upper) + str = "signal SIGSEGV"; + AppendBounds(str, reinterpret_cast<lldb::addr_t>(info.si_lower), + reinterpret_cast<lldb::addr_t>(info.si_upper), + reinterpret_cast<lldb::addr_t>(info.si_addr)); +#else + str = GetCrashReasonString(reason, + reinterpret_cast<lldb::addr_t>(info.si_addr)); +#endif + } else { + str = GetCrashReasonString(reason, + reinterpret_cast<lldb::addr_t>(info.si_addr)); + } + return str; +} + +std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr) { + std::string str; + switch (reason) { default: assert(false && "invalid CrashReason"); break; case CrashReason::eInvalidAddress: str = "signal SIGSEGV: invalid address"; - AppendFaultAddr(str, reinterpret_cast<lldb::addr_t>(info.si_addr)); + AppendFaultAddr(str, fault_addr); break; case CrashReason::ePrivilegedAddress: str = "signal SIGSEGV: address access protected"; - AppendFaultAddr(str, reinterpret_cast<lldb::addr_t>(info.si_addr)); + AppendFaultAddr(str, fault_addr); break; case CrashReason::eBoundViolation: - str = "signal SIGSEGV"; -// Make sure that siginfo_t has the bound fields available. -#if defined(si_lower) && defined(si_upper) - AppendBounds(str, reinterpret_cast<lldb::addr_t>(info.si_lower), - reinterpret_cast<lldb::addr_t>(info.si_upper), - reinterpret_cast<lldb::addr_t>(info.si_addr)); -#endif + str = "signal SIGSEGV: bound violation"; break; case CrashReason::eIllegalOpcode: str = "signal SIGILL: illegal instruction";
Index: source/Plugins/Process/POSIX/CrashReason.h =================================================================== --- source/Plugins/Process/POSIX/CrashReason.h +++ source/Plugins/Process/POSIX/CrashReason.h @@ -50,6 +50,7 @@ eFloatSubscriptRange }; +std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr); std::string GetCrashReasonString(CrashReason reason, const siginfo_t &info); const char *CrashReasonAsString(CrashReason reason); Index: source/Plugins/Process/POSIX/CrashReason.cpp =================================================================== --- source/Plugins/Process/POSIX/CrashReason.cpp +++ source/Plugins/Process/POSIX/CrashReason.cpp @@ -136,27 +136,42 @@ std::string GetCrashReasonString(CrashReason reason, const siginfo_t &info) { std::string str; + if (reason == CrashReason::eBoundViolation) { +// make sure that siginfo_t has the bound fields available. +#if defined(si_lower) && defined(si_upper) + str = "signal SIGSEGV"; + AppendBounds(str, reinterpret_cast<lldb::addr_t>(info.si_lower), + reinterpret_cast<lldb::addr_t>(info.si_upper), + reinterpret_cast<lldb::addr_t>(info.si_addr)); +#else + str = GetCrashReasonString(reason, + reinterpret_cast<lldb::addr_t>(info.si_addr)); +#endif + } else { + str = GetCrashReasonString(reason, + reinterpret_cast<lldb::addr_t>(info.si_addr)); + } + return str; +} + +std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr) { + std::string str; + switch (reason) { default: assert(false && "invalid CrashReason"); break; case CrashReason::eInvalidAddress: str = "signal SIGSEGV: invalid address"; - AppendFaultAddr(str, reinterpret_cast<lldb::addr_t>(info.si_addr)); + AppendFaultAddr(str, fault_addr); break; case CrashReason::ePrivilegedAddress: str = "signal SIGSEGV: address access protected"; - AppendFaultAddr(str, reinterpret_cast<lldb::addr_t>(info.si_addr)); + AppendFaultAddr(str, fault_addr); break; case CrashReason::eBoundViolation: - str = "signal SIGSEGV"; -// Make sure that siginfo_t has the bound fields available. -#if defined(si_lower) && defined(si_upper) - AppendBounds(str, reinterpret_cast<lldb::addr_t>(info.si_lower), - reinterpret_cast<lldb::addr_t>(info.si_upper), - reinterpret_cast<lldb::addr_t>(info.si_addr)); -#endif + str = "signal SIGSEGV: bound violation"; break; case CrashReason::eIllegalOpcode: str = "signal SIGILL: illegal instruction";
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits