1 //===-- asan_test_utils.h ---------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of AddressSanitizer, an address sanity checker.
10 //===----------------------------------------------------------------------===//
12 #ifndef ASAN_TEST_UTILS_H
13 #define ASAN_TEST_UTILS_H
15 #if !defined(SANITIZER_EXTERNAL_TEST_CONFIG)
16 # define INCLUDED_FROM_ASAN_TEST_UTILS_H
17 # include "asan_test_config.h"
18 # undef INCLUDED_FROM_ASAN_TEST_UTILS_H
21 #include "sanitizer_test_utils.h"
22 #include "sanitizer_pthread_wrappers.h"
34 # include <sys/mman.h>
39 # include <sys/prctl.h>
40 # include <sys/types.h>
41 # include <sys/stat.h>
45 #if defined(__linux__) || defined(__FreeBSD__)
49 #if !defined(__APPLE__) && !defined(__FreeBSD__)
53 #if ASAN_HAS_EXCEPTIONS
54 # define ASAN_THROW(x) throw (x)
56 # define ASAN_THROW(x)
64 static const int kPageSize
= 4096;
66 const size_t kLargeMalloc
= 1 << 24;
68 extern void free_aaa(void *p
);
69 extern void *malloc_aaa(size_t size
);
72 NOINLINE
void asan_write(T
*a
) {
76 string
RightOOBErrorMessage(int oob_distance
, bool is_write
);
77 string
RightOOBWriteMessage(int oob_distance
);
78 string
RightOOBReadMessage(int oob_distance
);
79 string
LeftOOBErrorMessage(int oob_distance
, bool is_write
);
80 string
LeftOOBWriteMessage(int oob_distance
);
81 string
LeftOOBReadMessage(int oob_distance
);
82 string
LeftOOBAccessMessage(int oob_distance
);
83 char* MallocAndMemsetString(size_t size
, char ch
);
84 char* MallocAndMemsetString(size_t size
);
95 extern char glob10
[10];
96 extern char glob11
[11];
97 extern char glob12
[12];
98 extern char glob13
[13];
99 extern char glob14
[14];
100 extern char glob15
[15];
101 extern char glob16
[16];
102 extern char glob17
[17];
103 extern char glob1000
[1000];
104 extern char glob10000
[10000];
105 extern char glob100000
[100000];
106 extern int GlobalsTest(int x
);
108 #endif // ASAN_TEST_UTILS_H