]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/asan/asan_report.h
Import compiler-rt 3.7.0 release (r246257).
[FreeBSD/FreeBSD.git] / lib / asan / asan_report.h
1 //===-- asan_report.h -------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of AddressSanitizer, an address sanity checker.
11 //
12 // ASan-private header for error reporting functions.
13 //===----------------------------------------------------------------------===//
14
15 #include "asan_allocator.h"
16 #include "asan_internal.h"
17 #include "asan_thread.h"
18
19 namespace __asan {
20
21 struct StackVarDescr {
22   uptr beg;
23   uptr size;
24   const char *name_pos;
25   uptr name_len;
26 };
27
28 struct AddressDescription {
29   char *name;
30   uptr name_size;
31   uptr region_address;
32   uptr region_size;
33   const char *region_kind;
34 };
35
36 // Returns the number of globals close to the provided address and copies
37 // them to "globals" array.
38 int GetGlobalsForAddress(uptr addr, __asan_global *globals, u32 *reg_sites,
39                          int max_globals);
40 bool GetInfoForAddressIfGlobal(uptr addr, AddressDescription *descr);
41 // The following functions prints address description depending
42 // on the memory type (shadow/heap/stack/global).
43 void DescribeHeapAddress(uptr addr, uptr access_size);
44 bool DescribeAddressIfShadow(uptr addr, AddressDescription *descr = nullptr,
45                              bool print = true);
46 bool ParseFrameDescription(const char *frame_descr,
47                            InternalMmapVector<StackVarDescr> *vars);
48 bool DescribeAddressIfStack(uptr addr, uptr access_size);
49 void DescribeThread(AsanThreadContext *context);
50
51 // Different kinds of error reports.
52 void NORETURN ReportStackOverflow(const SignalContext &sig);
53 void NORETURN ReportSIGSEGV(const char *description, const SignalContext &sig);
54 void NORETURN ReportNewDeleteSizeMismatch(uptr addr, uptr delete_size,
55                                           BufferedStackTrace *free_stack);
56 void NORETURN ReportDoubleFree(uptr addr, BufferedStackTrace *free_stack);
57 void NORETURN ReportFreeNotMalloced(uptr addr, BufferedStackTrace *free_stack);
58 void NORETURN ReportAllocTypeMismatch(uptr addr, BufferedStackTrace *free_stack,
59                                       AllocType alloc_type,
60                                       AllocType dealloc_type);
61 void NORETURN
62     ReportMallocUsableSizeNotOwned(uptr addr, BufferedStackTrace *stack);
63 void NORETURN
64     ReportSanitizerGetAllocatedSizeNotOwned(uptr addr,
65                                             BufferedStackTrace *stack);
66 void NORETURN
67     ReportStringFunctionMemoryRangesOverlap(const char *function,
68                                             const char *offset1, uptr length1,
69                                             const char *offset2, uptr length2,
70                                             BufferedStackTrace *stack);
71 void NORETURN ReportStringFunctionSizeOverflow(uptr offset, uptr size,
72                                                BufferedStackTrace *stack);
73 void NORETURN
74     ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,
75                                                  uptr old_mid, uptr new_mid,
76                                                  BufferedStackTrace *stack);
77
78 void NORETURN
79 ReportODRViolation(const __asan_global *g1, u32 stack_id1,
80                    const __asan_global *g2, u32 stack_id2);
81
82 // Mac-specific errors and warnings.
83 void WarnMacFreeUnallocated(uptr addr, uptr zone_ptr, const char *zone_name,
84                             BufferedStackTrace *stack);
85 void NORETURN ReportMacMzReallocUnknown(uptr addr, uptr zone_ptr,
86                                         const char *zone_name,
87                                         BufferedStackTrace *stack);
88 void NORETURN ReportMacCfReallocUnknown(uptr addr, uptr zone_ptr,
89                                         const char *zone_name,
90                                         BufferedStackTrace *stack);
91
92 }  // namespace __asan