1 //===-- CrashReason.h -------------------------------------------*- C++ -*-===//
2 //
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
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 
18 enum class CrashReason {
19   eInvalidCrashReason,
20 
21   // SIGSEGV crash reasons.
22   eInvalidAddress,
23   ePrivilegedAddress,
24   eBoundViolation,
25 
26   // SIGILL crash reasons.
27   eIllegalOpcode,
28   eIllegalOperand,
29   eIllegalAddressingMode,
30   eIllegalTrap,
31   ePrivilegedOpcode,
32   ePrivilegedRegister,
33   eCoprocessorError,
34   eInternalStackError,
35 
36   // SIGBUS crash reasons,
37   eIllegalAlignment,
38   eIllegalAddress,
39   eHardwareError,
40 
41   // SIGFPE crash reasons,
42   eIntegerDivideByZero,
43   eIntegerOverflow,
44   eFloatDivideByZero,
45   eFloatOverflow,
46   eFloatUnderflow,
47   eFloatInexactResult,
48   eFloatInvalidOperation,
49   eFloatSubscriptRange
50 };
51 
52 std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr);
53 std::string GetCrashReasonString(CrashReason reason, const siginfo_t &info);
54 
55 const char *CrashReasonAsString(CrashReason reason);
56 
57 CrashReason GetCrashReason(const siginfo_t &info);
58 
59 #endif // #ifndef liblldb_CrashReason_H_
60