[libsanitizer merge from upstream r218156]
[gcc.git] / libsanitizer / asan / asan_report.h
1 //===-- asan_report.h -------------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // ASan-private header for error reporting functions.
11 //===----------------------------------------------------------------------===//
12
13 #include "asan_allocator.h"
14 #include "asan_internal.h"
15 #include "asan_thread.h"
16
17 namespace __asan {
18
19 struct StackVarDescr {
20 uptr beg;
21 uptr size;
22 const char *name_pos;
23 uptr name_len;
24 };
25
26 // The following functions prints address description depending
27 // on the memory type (shadow/heap/stack/global).
28 void DescribeHeapAddress(uptr addr, uptr access_size);
29 bool DescribeAddressIfGlobal(uptr addr, uptr access_size);
30 bool DescribeAddressRelativeToGlobal(uptr addr, uptr access_size,
31 const __asan_global &g);
32 bool DescribeAddressIfShadow(uptr addr);
33 bool ParseFrameDescription(const char *frame_descr,
34 InternalMmapVector<StackVarDescr> *vars);
35 bool DescribeAddressIfStack(uptr addr, uptr access_size);
36 // Determines memory type on its own.
37 void DescribeAddress(uptr addr, uptr access_size);
38
39 void DescribeThread(AsanThreadContext *context);
40
41 // Different kinds of error reports.
42 void NORETURN
43 ReportStackOverflow(uptr pc, uptr sp, uptr bp, void *context, uptr addr);
44 void NORETURN ReportSIGSEGV(const char *description, uptr pc, uptr sp, uptr bp,
45 void *context, uptr addr);
46 void NORETURN ReportNewDeleteSizeMismatch(uptr addr, uptr delete_size,
47 StackTrace *free_stack);
48 void NORETURN ReportDoubleFree(uptr addr, StackTrace *free_stack);
49 void NORETURN ReportFreeNotMalloced(uptr addr, StackTrace *free_stack);
50 void NORETURN ReportAllocTypeMismatch(uptr addr, StackTrace *free_stack,
51 AllocType alloc_type,
52 AllocType dealloc_type);
53 void NORETURN ReportMallocUsableSizeNotOwned(uptr addr,
54 StackTrace *stack);
55 void NORETURN
56 ReportSanitizerGetAllocatedSizeNotOwned(uptr addr, StackTrace *stack);
57 void NORETURN ReportStringFunctionMemoryRangesOverlap(
58 const char *function, const char *offset1, uptr length1,
59 const char *offset2, uptr length2, StackTrace *stack);
60 void NORETURN
61 ReportStringFunctionSizeOverflow(uptr offset, uptr size, StackTrace *stack);
62 void NORETURN
63 ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end, uptr old_mid,
64 uptr new_mid, StackTrace *stack);
65
66 void NORETURN
67 ReportODRViolation(const __asan_global *g1, u32 stack_id1,
68 const __asan_global *g2, u32 stack_id2);
69
70 // Mac-specific errors and warnings.
71 void WarnMacFreeUnallocated(
72 uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack);
73 void NORETURN ReportMacMzReallocUnknown(
74 uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack);
75 void NORETURN ReportMacCfReallocUnknown(
76 uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack);
77
78 } // namespace __asan