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