Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 1 | //===-- CrashReason.h -------------------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef liblldb_CrashReason_H_ |
| 10 | #define liblldb_CrashReason_H_ |
| 11 | |
| 12 | #include "lldb/lldb-types.h" |
| 13 | |
| 14 | #include <signal.h> |
| 15 | |
| 16 | #include <string> |
| 17 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 18 | enum class CrashReason { |
| 19 | eInvalidCrashReason, |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 20 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 21 | // SIGSEGV crash reasons. |
| 22 | eInvalidAddress, |
| 23 | ePrivilegedAddress, |
Valentina Giusti | 6f8c1f8 | 2016-10-06 18:05:12 +0000 | [diff] [blame] | 24 | eBoundViolation, |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 25 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 26 | // SIGILL crash reasons. |
| 27 | eIllegalOpcode, |
| 28 | eIllegalOperand, |
| 29 | eIllegalAddressingMode, |
| 30 | eIllegalTrap, |
| 31 | ePrivilegedOpcode, |
| 32 | ePrivilegedRegister, |
| 33 | eCoprocessorError, |
| 34 | eInternalStackError, |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 35 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 36 | // SIGBUS crash reasons, |
| 37 | eIllegalAlignment, |
| 38 | eIllegalAddress, |
| 39 | eHardwareError, |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 40 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 41 | // SIGFPE crash reasons, |
| 42 | eIntegerDivideByZero, |
| 43 | eIntegerOverflow, |
| 44 | eFloatDivideByZero, |
| 45 | eFloatOverflow, |
| 46 | eFloatUnderflow, |
| 47 | eFloatInexactResult, |
| 48 | eFloatInvalidOperation, |
| 49 | eFloatSubscriptRange |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
Valentina Giusti | 1c2c728 | 2016-10-07 13:21:59 +0000 | [diff] [blame] | 52 | std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr); |
Valentina Giusti | 6f8c1f8 | 2016-10-06 18:05:12 +0000 | [diff] [blame] | 53 | std::string GetCrashReasonString(CrashReason reason, const siginfo_t &info); |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 54 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 55 | const char *CrashReasonAsString(CrashReason reason); |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 56 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 57 | CrashReason GetCrashReason(const siginfo_t &info); |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 58 | |
| 59 | #endif // #ifndef liblldb_CrashReason_H_ |