Path: blob/main/contrib/llvm-project/compiler-rt/lib/asan/asan_report.h
35233 views
//===-- asan_report.h -------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file is a part of AddressSanitizer, an address sanity checker.9//10// ASan-private header for error reporting functions.11//===----------------------------------------------------------------------===//1213#ifndef ASAN_REPORT_H14#define ASAN_REPORT_H1516#include "asan_allocator.h"17#include "asan_internal.h"18#include "asan_thread.h"1920namespace __asan {2122struct StackVarDescr {23uptr beg;24uptr size;25const char *name_pos;26uptr name_len;27uptr line;28};2930// Returns the number of globals close to the provided address and copies31// them to "globals" array.32int GetGlobalsForAddress(uptr addr, __asan_global *globals, u32 *reg_sites,33int max_globals);3435const char *MaybeDemangleGlobalName(const char *name);36void PrintGlobalNameIfASCII(InternalScopedString *str, const __asan_global &g);37void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g,38bool print_module_name);3940void PrintMemoryByte(InternalScopedString *str, const char *before, u8 byte,41bool in_shadow, const char *after = "\n");4243// The following functions prints address description depending44// on the memory type (shadow/heap/stack/global).45bool ParseFrameDescription(const char *frame_descr,46InternalMmapVector<StackVarDescr> *vars);4748// Different kinds of error reports.49void ReportGenericError(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write,50uptr access_size, u32 exp, bool fatal);51void ReportDeadlySignal(const SignalContext &sig);52void ReportNewDeleteTypeMismatch(uptr addr, uptr delete_size,53uptr delete_alignment,54BufferedStackTrace *free_stack);55void ReportDoubleFree(uptr addr, BufferedStackTrace *free_stack);56void ReportFreeNotMalloced(uptr addr, BufferedStackTrace *free_stack);57void ReportAllocTypeMismatch(uptr addr, BufferedStackTrace *free_stack,58AllocType alloc_type,59AllocType dealloc_type);60void ReportMallocUsableSizeNotOwned(uptr addr, BufferedStackTrace *stack);61void ReportSanitizerGetAllocatedSizeNotOwned(uptr addr,62BufferedStackTrace *stack);63void ReportCallocOverflow(uptr count, uptr size, BufferedStackTrace *stack);64void ReportReallocArrayOverflow(uptr count, uptr size,65BufferedStackTrace *stack);66void ReportPvallocOverflow(uptr size, BufferedStackTrace *stack);67void ReportInvalidAllocationAlignment(uptr alignment,68BufferedStackTrace *stack);69void ReportInvalidAlignedAllocAlignment(uptr size, uptr alignment,70BufferedStackTrace *stack);71void ReportInvalidPosixMemalignAlignment(uptr alignment,72BufferedStackTrace *stack);73void ReportAllocationSizeTooBig(uptr user_size, uptr total_size, uptr max_size,74BufferedStackTrace *stack);75void ReportRssLimitExceeded(BufferedStackTrace *stack);76void ReportOutOfMemory(uptr requested_size, BufferedStackTrace *stack);77void ReportStringFunctionMemoryRangesOverlap(const char *function,78const char *offset1, uptr length1,79const char *offset2, uptr length2,80BufferedStackTrace *stack);81void ReportStringFunctionSizeOverflow(uptr offset, uptr size,82BufferedStackTrace *stack);83void ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,84uptr old_mid, uptr new_mid,85BufferedStackTrace *stack);86void ReportBadParamsToAnnotateDoubleEndedContiguousContainer(87uptr storage_beg, uptr storage_end, uptr old_container_beg,88uptr old_container_end, uptr new_container_beg, uptr new_container_end,89BufferedStackTrace *stack);9091void ReportODRViolation(const __asan_global *g1, u32 stack_id1,92const __asan_global *g2, u32 stack_id2);9394// Mac-specific errors and warnings.95void ReportMacMzReallocUnknown(uptr addr, uptr zone_ptr,96const char *zone_name,97BufferedStackTrace *stack);98void ReportMacCfReallocUnknown(uptr addr, uptr zone_ptr,99const char *zone_name,100BufferedStackTrace *stack);101102} // namespace __asan103#endif // ASAN_REPORT_H104105106