]> git.ipfire.org Git - thirdparty/gcc.git/blob - libsanitizer/asan/asan_report.h
libsanitizer merge from upstream r253555.
[thirdparty/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 struct AddressDescription {
27 char *name;
28 uptr name_size;
29 uptr region_address;
30 uptr region_size;
31 const char *region_kind;
32 };
33
34 // Returns the number of globals close to the provided address and copies
35 // them to "globals" array.
36 int GetGlobalsForAddress(uptr addr, __asan_global *globals, u32 *reg_sites,
37 int max_globals);
38 bool GetInfoForAddressIfGlobal(uptr addr, AddressDescription *descr);
39 // The following functions prints address description depending
40 // on the memory type (shadow/heap/stack/global).
41 void DescribeHeapAddress(uptr addr, uptr access_size);
42 bool DescribeAddressIfShadow(uptr addr, AddressDescription *descr = nullptr,
43 bool print = true);
44 bool ParseFrameDescription(const char *frame_descr,
45 InternalMmapVector<StackVarDescr> *vars);
46 bool DescribeAddressIfStack(uptr addr, uptr access_size);
47 void DescribeThread(AsanThreadContext *context);
48
49 // Different kinds of error reports.
50 void ReportGenericError(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write,
51 uptr access_size, u32 exp, bool fatal);
52 void ReportStackOverflow(const SignalContext &sig);
53 void ReportDeadlySignal(const char *description, const SignalContext &sig);
54 void ReportNewDeleteSizeMismatch(uptr addr, uptr delete_size,
55 BufferedStackTrace *free_stack);
56 void ReportDoubleFree(uptr addr, BufferedStackTrace *free_stack);
57 void ReportFreeNotMalloced(uptr addr, BufferedStackTrace *free_stack);
58 void ReportAllocTypeMismatch(uptr addr, BufferedStackTrace *free_stack,
59 AllocType alloc_type,
60 AllocType dealloc_type);
61 void ReportMallocUsableSizeNotOwned(uptr addr, BufferedStackTrace *stack);
62 void ReportSanitizerGetAllocatedSizeNotOwned(uptr addr,
63 BufferedStackTrace *stack);
64 void ReportStringFunctionMemoryRangesOverlap(const char *function,
65 const char *offset1, uptr length1,
66 const char *offset2, uptr length2,
67 BufferedStackTrace *stack);
68 void ReportStringFunctionSizeOverflow(uptr offset, uptr size,
69 BufferedStackTrace *stack);
70 void ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,
71 uptr old_mid, uptr new_mid,
72 BufferedStackTrace *stack);
73
74 void ReportODRViolation(const __asan_global *g1, u32 stack_id1,
75 const __asan_global *g2, u32 stack_id2);
76
77 // Mac-specific errors and warnings.
78 void WarnMacFreeUnallocated(uptr addr, uptr zone_ptr, const char *zone_name,
79 BufferedStackTrace *stack);
80 void ReportMacMzReallocUnknown(uptr addr, uptr zone_ptr,
81 const char *zone_name,
82 BufferedStackTrace *stack);
83 void ReportMacCfReallocUnknown(uptr addr, uptr zone_ptr,
84 const char *zone_name,
85 BufferedStackTrace *stack);
86
87 } // namespace __asan