blob: 9b4784a1e68e1dc672d841fe67102a560b48239c [file] [log] [blame]
Chaoren Lin28e57422015-02-03 01:51:25 +00001//===-- CrashReason.h -------------------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Lin28e57422015-02-03 01:51:25 +00006//
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 Stoneb9c1b512016-09-06 20:57:50 +000018enum class CrashReason {
19 eInvalidCrashReason,
Chaoren Lin28e57422015-02-03 01:51:25 +000020
Kate Stoneb9c1b512016-09-06 20:57:50 +000021 // SIGSEGV crash reasons.
22 eInvalidAddress,
23 ePrivilegedAddress,
Valentina Giusti6f8c1f82016-10-06 18:05:12 +000024 eBoundViolation,
Chaoren Lin28e57422015-02-03 01:51:25 +000025
Kate Stoneb9c1b512016-09-06 20:57:50 +000026 // SIGILL crash reasons.
27 eIllegalOpcode,
28 eIllegalOperand,
29 eIllegalAddressingMode,
30 eIllegalTrap,
31 ePrivilegedOpcode,
32 ePrivilegedRegister,
33 eCoprocessorError,
34 eInternalStackError,
Chaoren Lin28e57422015-02-03 01:51:25 +000035
Kate Stoneb9c1b512016-09-06 20:57:50 +000036 // SIGBUS crash reasons,
37 eIllegalAlignment,
38 eIllegalAddress,
39 eHardwareError,
Chaoren Lin28e57422015-02-03 01:51:25 +000040
Kate Stoneb9c1b512016-09-06 20:57:50 +000041 // SIGFPE crash reasons,
42 eIntegerDivideByZero,
43 eIntegerOverflow,
44 eFloatDivideByZero,
45 eFloatOverflow,
46 eFloatUnderflow,
47 eFloatInexactResult,
48 eFloatInvalidOperation,
49 eFloatSubscriptRange
Chaoren Lin28e57422015-02-03 01:51:25 +000050};
51
Valentina Giusti1c2c7282016-10-07 13:21:59 +000052std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr);
Valentina Giusti6f8c1f82016-10-06 18:05:12 +000053std::string GetCrashReasonString(CrashReason reason, const siginfo_t &info);
Chaoren Lin28e57422015-02-03 01:51:25 +000054
Kate Stoneb9c1b512016-09-06 20:57:50 +000055const char *CrashReasonAsString(CrashReason reason);
Chaoren Lin28e57422015-02-03 01:51:25 +000056
Kate Stoneb9c1b512016-09-06 20:57:50 +000057CrashReason GetCrashReason(const siginfo_t &info);
Chaoren Lin28e57422015-02-03 01:51:25 +000058
59#endif // #ifndef liblldb_CrashReason_H_