| 1 | //===-- report.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 SCUDO_REPORT_H_ |
| 10 | #define SCUDO_REPORT_H_ |
| 11 | |
| 12 | #include "internal_defs.h" |
| 13 | |
| 14 | namespace scudo { |
| 15 | // Reports are *fatal* unless stated otherwise. |
| 16 | |
| 17 | // Generic error, adds newline to end of message. |
| 18 | void NORETURN reportError(const char *Message); |
| 19 | |
| 20 | // Generic error, but the message is not modified. |
| 21 | void NORETURN reportRawError(const char *Message); |
| 22 | |
| 23 | // Flags related errors. |
| 24 | void NORETURN reportInvalidFlag(const char *FlagType, const char *Value); |
| 25 | |
| 26 | // Chunk header related errors. |
| 27 | void NORETURN (void *, const void *Ptr); |
| 28 | |
| 29 | // Sanity checks related error. |
| 30 | void NORETURN reportSanityCheckError(const char *Field); |
| 31 | |
| 32 | // Combined allocator errors. |
| 33 | void NORETURN reportAlignmentTooBig(uptr Alignment, uptr MaxAlignment); |
| 34 | void NORETURN reportAllocationSizeTooBig(uptr UserSize, uptr TotalSize, |
| 35 | uptr MaxSize); |
| 36 | void NORETURN reportOutOfBatchClass(); |
| 37 | void NORETURN reportOutOfMemory(uptr RequestedSize); |
| 38 | enum class AllocatorAction : u8 { |
| 39 | Recycling, |
| 40 | Deallocating, |
| 41 | Reallocating, |
| 42 | Sizing, |
| 43 | }; |
| 44 | void NORETURN reportInvalidChunkState(AllocatorAction Action, const void *Ptr); |
| 45 | void NORETURN reportMisalignedPointer(AllocatorAction Action, const void *Ptr); |
| 46 | void NORETURN reportDeallocTypeMismatch(AllocatorAction Action, const void *Ptr, |
| 47 | u8 TypeA, u8 TypeB); |
| 48 | void NORETURN reportDeleteSizeMismatch(const void *Ptr, uptr Size, |
| 49 | uptr ExpectedSize); |
| 50 | |
| 51 | // C wrappers errors. |
| 52 | void NORETURN reportAlignmentNotPowerOfTwo(uptr Alignment); |
| 53 | void NORETURN reportInvalidPosixMemalignAlignment(uptr Alignment); |
| 54 | void NORETURN reportCallocOverflow(uptr Count, uptr Size); |
| 55 | void NORETURN reportPvallocOverflow(uptr Size); |
| 56 | void NORETURN reportInvalidAlignedAllocAlignment(uptr Size, uptr Alignment); |
| 57 | |
| 58 | } // namespace scudo |
| 59 | |
| 60 | #endif // SCUDO_REPORT_H_ |
| 61 | |