Alexey Samsonov | 7354509 | 2012-08-09 07:40:58 +0000 | [diff] [blame] | 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 | |
Kostya Serebryany | fe6d916 | 2012-12-21 08:53:59 +0000 | [diff] [blame] | 15 | #include "asan_allocator.h" |
Alexey Samsonov | 7354509 | 2012-08-09 07:40:58 +0000 | [diff] [blame] | 16 | #include "asan_internal.h" |
Alexey Samsonov | 71b42c9 | 2012-09-05 07:37:15 +0000 | [diff] [blame] | 17 | #include "asan_thread.h" |
Alexey Samsonov | 7354509 | 2012-08-09 07:40:58 +0000 | [diff] [blame] | 18 | |
| 19 | namespace __asan { |
| 20 | |
Alexey Samsonov | e218beb | 2012-08-09 09:06:52 +0000 | [diff] [blame] | 21 | // The following functions prints address description depending |
| 22 | // on the memory type (shadow/heap/stack/global). |
| 23 | void DescribeHeapAddress(uptr addr, uptr access_size); |
Evgeniy Stepanov | 589dcda | 2013-02-05 14:32:03 +0000 | [diff] [blame] | 24 | bool DescribeAddressIfGlobal(uptr addr, uptr access_size); |
| 25 | bool DescribeAddressRelativeToGlobal(uptr addr, uptr access_size, |
| 26 | const __asan_global &g); |
Alexey Samsonov | e218beb | 2012-08-09 09:06:52 +0000 | [diff] [blame] | 27 | bool DescribeAddressIfShadow(uptr addr); |
| 28 | bool DescribeAddressIfStack(uptr addr, uptr access_size); |
| 29 | // Determines memory type on its own. |
| 30 | void DescribeAddress(uptr addr, uptr access_size); |
| 31 | |
Alexey Samsonov | def1be9 | 2013-03-21 11:23:41 +0000 | [diff] [blame] | 32 | void DescribeThread(AsanThreadContext *context); |
Alexey Samsonov | 71b42c9 | 2012-09-05 07:37:15 +0000 | [diff] [blame] | 33 | |
Alexey Samsonov | e218beb | 2012-08-09 09:06:52 +0000 | [diff] [blame] | 34 | // Different kinds of error reports. |
Alexey Samsonov | f7c1d18 | 2012-08-09 08:15:46 +0000 | [diff] [blame] | 35 | void NORETURN ReportSIGSEGV(uptr pc, uptr sp, uptr bp, uptr addr); |
Kostya Serebryany | c3390df | 2012-08-28 11:54:30 +0000 | [diff] [blame] | 36 | void NORETURN ReportDoubleFree(uptr addr, StackTrace *stack); |
| 37 | void NORETURN ReportFreeNotMalloced(uptr addr, StackTrace *stack); |
Kostya Serebryany | fe6d916 | 2012-12-21 08:53:59 +0000 | [diff] [blame] | 38 | void NORETURN ReportAllocTypeMismatch(uptr addr, StackTrace *stack, |
| 39 | AllocType alloc_type, |
| 40 | AllocType dealloc_type); |
Alexey Samsonov | f7c1d18 | 2012-08-09 08:15:46 +0000 | [diff] [blame] | 41 | void NORETURN ReportMallocUsableSizeNotOwned(uptr addr, |
Kostya Serebryany | c3390df | 2012-08-28 11:54:30 +0000 | [diff] [blame] | 42 | StackTrace *stack); |
Alexey Samsonov | f7c1d18 | 2012-08-09 08:15:46 +0000 | [diff] [blame] | 43 | void NORETURN ReportAsanGetAllocatedSizeNotOwned(uptr addr, |
Kostya Serebryany | c3390df | 2012-08-28 11:54:30 +0000 | [diff] [blame] | 44 | StackTrace *stack); |
Alexey Samsonov | 487fee7 | 2012-08-09 08:32:33 +0000 | [diff] [blame] | 45 | void NORETURN ReportStringFunctionMemoryRangesOverlap( |
| 46 | const char *function, const char *offset1, uptr length1, |
Kostya Serebryany | c3390df | 2012-08-28 11:54:30 +0000 | [diff] [blame] | 47 | const char *offset2, uptr length2, StackTrace *stack); |
Alexey Samsonov | 7354509 | 2012-08-09 07:40:58 +0000 | [diff] [blame] | 48 | |
Alexey Samsonov | 663c501 | 2012-08-09 12:15:40 +0000 | [diff] [blame] | 49 | // Mac-specific errors and warnings. |
| 50 | void WarnMacFreeUnallocated( |
Kostya Serebryany | c3390df | 2012-08-28 11:54:30 +0000 | [diff] [blame] | 51 | uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack); |
Alexey Samsonov | 663c501 | 2012-08-09 12:15:40 +0000 | [diff] [blame] | 52 | void NORETURN ReportMacMzReallocUnknown( |
Kostya Serebryany | c3390df | 2012-08-28 11:54:30 +0000 | [diff] [blame] | 53 | uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack); |
Alexey Samsonov | 663c501 | 2012-08-09 12:15:40 +0000 | [diff] [blame] | 54 | void NORETURN ReportMacCfReallocUnknown( |
Kostya Serebryany | c3390df | 2012-08-28 11:54:30 +0000 | [diff] [blame] | 55 | uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack); |
Alexey Samsonov | 663c501 | 2012-08-09 12:15:40 +0000 | [diff] [blame] | 56 | |
Alexey Samsonov | 7354509 | 2012-08-09 07:40:58 +0000 | [diff] [blame] | 57 | } // namespace __asan |