10b57cec5SDimitry Andric //===-- report.h ------------------------------------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #ifndef SCUDO_REPORT_H_ 100b57cec5SDimitry Andric #define SCUDO_REPORT_H_ 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include "internal_defs.h" 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric namespace scudo { 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric // Reports are *fatal* unless stated otherwise. 170b57cec5SDimitry Andric 18*5f757f3fSDimitry Andric // Generic error, adds newline to end of message. 190b57cec5SDimitry Andric void NORETURN reportError(const char *Message); 200b57cec5SDimitry Andric 21*5f757f3fSDimitry Andric // Generic error, but the message is not modified. 22*5f757f3fSDimitry Andric void NORETURN reportRawError(const char *Message); 23*5f757f3fSDimitry Andric 240b57cec5SDimitry Andric // Flags related errors. 250b57cec5SDimitry Andric void NORETURN reportInvalidFlag(const char *FlagType, const char *Value); 260b57cec5SDimitry Andric 270b57cec5SDimitry Andric // Chunk header related errors. 280b57cec5SDimitry Andric void NORETURN reportHeaderCorruption(void *Ptr); 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric // Sanity checks related error. 310b57cec5SDimitry Andric void NORETURN reportSanityCheckError(const char *Field); 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric // Combined allocator errors. 340b57cec5SDimitry Andric void NORETURN reportAlignmentTooBig(uptr Alignment, uptr MaxAlignment); 350b57cec5SDimitry Andric void NORETURN reportAllocationSizeTooBig(uptr UserSize, uptr TotalSize, 360b57cec5SDimitry Andric uptr MaxSize); 3706c3fb27SDimitry Andric void NORETURN reportOutOfBatchClass(); 380b57cec5SDimitry Andric void NORETURN reportOutOfMemory(uptr RequestedSize); 390b57cec5SDimitry Andric enum class AllocatorAction : u8 { 400b57cec5SDimitry Andric Recycling, 410b57cec5SDimitry Andric Deallocating, 420b57cec5SDimitry Andric Reallocating, 430b57cec5SDimitry Andric Sizing, 440b57cec5SDimitry Andric }; 450b57cec5SDimitry Andric void NORETURN reportInvalidChunkState(AllocatorAction Action, void *Ptr); 460b57cec5SDimitry Andric void NORETURN reportMisalignedPointer(AllocatorAction Action, void *Ptr); 470b57cec5SDimitry Andric void NORETURN reportDeallocTypeMismatch(AllocatorAction Action, void *Ptr, 480b57cec5SDimitry Andric u8 TypeA, u8 TypeB); 490b57cec5SDimitry Andric void NORETURN reportDeleteSizeMismatch(void *Ptr, uptr Size, uptr ExpectedSize); 500b57cec5SDimitry Andric 510b57cec5SDimitry Andric // C wrappers errors. 520b57cec5SDimitry Andric void NORETURN reportAlignmentNotPowerOfTwo(uptr Alignment); 530b57cec5SDimitry Andric void NORETURN reportInvalidPosixMemalignAlignment(uptr Alignment); 540b57cec5SDimitry Andric void NORETURN reportCallocOverflow(uptr Count, uptr Size); 550b57cec5SDimitry Andric void NORETURN reportPvallocOverflow(uptr Size); 560b57cec5SDimitry Andric void NORETURN reportInvalidAlignedAllocAlignment(uptr Size, uptr Alignment); 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric } // namespace scudo 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric #endif // SCUDO_REPORT_H_ 61