]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/asan/asan_report.h
Merge compiler-rt trunk r291476.
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / 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 // Returns the number of globals close to the provided address and copies
29 // them to "globals" array.
30 int GetGlobalsForAddress(uptr addr, __asan_global *globals, u32 *reg_sites,
31                          int max_globals);
32
33 const char *MaybeDemangleGlobalName(const char *name);
34 void PrintGlobalNameIfASCII(InternalScopedString *str, const __asan_global &g);
35 void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g);
36
37 void PrintMemoryByte(InternalScopedString *str, const char *before, u8 byte,
38                      bool in_shadow, const char *after = "\n");
39
40 // The following functions prints address description depending
41 // on the memory type (shadow/heap/stack/global).
42 bool ParseFrameDescription(const char *frame_descr,
43                            InternalMmapVector<StackVarDescr> *vars);
44
45 // Different kinds of error reports.
46 void ReportGenericError(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write,
47                         uptr access_size, u32 exp, bool fatal);
48 void ReportStackOverflow(const SignalContext &sig);
49 void ReportDeadlySignal(int signo, const SignalContext &sig);
50 void ReportNewDeleteSizeMismatch(uptr addr, uptr delete_size,
51                                  BufferedStackTrace *free_stack);
52 void ReportDoubleFree(uptr addr, BufferedStackTrace *free_stack);
53 void ReportFreeNotMalloced(uptr addr, BufferedStackTrace *free_stack);
54 void ReportAllocTypeMismatch(uptr addr, BufferedStackTrace *free_stack,
55                              AllocType alloc_type,
56                              AllocType dealloc_type);
57 void ReportMallocUsableSizeNotOwned(uptr addr, BufferedStackTrace *stack);
58 void ReportSanitizerGetAllocatedSizeNotOwned(uptr addr,
59                                              BufferedStackTrace *stack);
60 void ReportStringFunctionMemoryRangesOverlap(const char *function,
61                                              const char *offset1, uptr length1,
62                                              const char *offset2, uptr length2,
63                                              BufferedStackTrace *stack);
64 void ReportStringFunctionSizeOverflow(uptr offset, uptr size,
65                                       BufferedStackTrace *stack);
66 void ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,
67                                                   uptr old_mid, uptr new_mid,
68                                                   BufferedStackTrace *stack);
69
70 void ReportODRViolation(const __asan_global *g1, u32 stack_id1,
71                         const __asan_global *g2, u32 stack_id2);
72
73 // Mac-specific errors and warnings.
74 void ReportMacMzReallocUnknown(uptr addr, uptr zone_ptr,
75                                const char *zone_name,
76                                BufferedStackTrace *stack);
77 void ReportMacCfReallocUnknown(uptr addr, uptr zone_ptr,
78                                const char *zone_name,
79                                BufferedStackTrace *stack);
80
81 }  // namespace __asan