blob: db271fc10e979b8a4d1fd1f8730ccfeab4b20c52 [file] [log] [blame]
Alexey Samsonov73545092012-08-09 07:40:58 +00001//===-- 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 Serebryanyfe6d9162012-12-21 08:53:59 +000015#include "asan_allocator.h"
Alexey Samsonov73545092012-08-09 07:40:58 +000016#include "asan_internal.h"
Alexey Samsonov71b42c92012-09-05 07:37:15 +000017#include "asan_thread.h"
Alexey Samsonov73545092012-08-09 07:40:58 +000018
19namespace __asan {
20
Alexey Samsonove218beb2012-08-09 09:06:52 +000021// The following functions prints address description depending
22// on the memory type (shadow/heap/stack/global).
23void DescribeHeapAddress(uptr addr, uptr access_size);
Evgeniy Stepanov589dcda2013-02-05 14:32:03 +000024bool DescribeAddressIfGlobal(uptr addr, uptr access_size);
25bool DescribeAddressRelativeToGlobal(uptr addr, uptr access_size,
26 const __asan_global &g);
Alexey Samsonove218beb2012-08-09 09:06:52 +000027bool DescribeAddressIfShadow(uptr addr);
28bool DescribeAddressIfStack(uptr addr, uptr access_size);
29// Determines memory type on its own.
30void DescribeAddress(uptr addr, uptr access_size);
31
Alexey Samsonovdef1be92013-03-21 11:23:41 +000032void DescribeThread(AsanThreadContext *context);
Alexey Samsonov71b42c92012-09-05 07:37:15 +000033
Alexey Samsonove218beb2012-08-09 09:06:52 +000034// Different kinds of error reports.
Alexey Samsonovf7c1d182012-08-09 08:15:46 +000035void NORETURN ReportSIGSEGV(uptr pc, uptr sp, uptr bp, uptr addr);
Kostya Serebryanyc3390df2012-08-28 11:54:30 +000036void NORETURN ReportDoubleFree(uptr addr, StackTrace *stack);
37void NORETURN ReportFreeNotMalloced(uptr addr, StackTrace *stack);
Kostya Serebryanyfe6d9162012-12-21 08:53:59 +000038void NORETURN ReportAllocTypeMismatch(uptr addr, StackTrace *stack,
39 AllocType alloc_type,
40 AllocType dealloc_type);
Alexey Samsonovf7c1d182012-08-09 08:15:46 +000041void NORETURN ReportMallocUsableSizeNotOwned(uptr addr,
Kostya Serebryanyc3390df2012-08-28 11:54:30 +000042 StackTrace *stack);
Alexey Samsonovf7c1d182012-08-09 08:15:46 +000043void NORETURN ReportAsanGetAllocatedSizeNotOwned(uptr addr,
Kostya Serebryanyc3390df2012-08-28 11:54:30 +000044 StackTrace *stack);
Alexey Samsonov487fee72012-08-09 08:32:33 +000045void NORETURN ReportStringFunctionMemoryRangesOverlap(
46 const char *function, const char *offset1, uptr length1,
Kostya Serebryanyc3390df2012-08-28 11:54:30 +000047 const char *offset2, uptr length2, StackTrace *stack);
Alexey Samsonov73545092012-08-09 07:40:58 +000048
Alexey Samsonov663c5012012-08-09 12:15:40 +000049// Mac-specific errors and warnings.
50void WarnMacFreeUnallocated(
Kostya Serebryanyc3390df2012-08-28 11:54:30 +000051 uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack);
Alexey Samsonov663c5012012-08-09 12:15:40 +000052void NORETURN ReportMacMzReallocUnknown(
Kostya Serebryanyc3390df2012-08-28 11:54:30 +000053 uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack);
Alexey Samsonov663c5012012-08-09 12:15:40 +000054void NORETURN ReportMacCfReallocUnknown(
Kostya Serebryanyc3390df2012-08-28 11:54:30 +000055 uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack);
Alexey Samsonov663c5012012-08-09 12:15:40 +000056
Alexey Samsonov73545092012-08-09 07:40:58 +000057} // namespace __asan