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(ASAN_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"
35 # include <sys/prctl.h>
36 # include <sys/types.h>
37 # include <sys/stat.h>
42 #if defined(__i386__) || defined(__x86_64__)
43 #include <emmintrin.h>
50 // Check that pthread_create/pthread_join return success.
51 #define PTHREAD_CREATE(a, b, c, d) ASSERT_EQ(0, pthread_create(a, b, c, d))
52 #define PTHREAD_JOIN(a, b) ASSERT_EQ(0, pthread_join(a, b))
54 #if ASAN_HAS_EXCEPTIONS
55 # define ASAN_THROW(x) throw (x)
57 # define ASAN_THROW(x)
65 static const int kPageSize = 4096;
67 const size_t kLargeMalloc = 1 << 24;
69 extern void free_aaa(void *p);
70 extern void *malloc_aaa(size_t size);
73 NOINLINE void asan_write(T *a) {
77 string RightOOBErrorMessage(int oob_distance, bool is_write);
78 string RightOOBWriteMessage(int oob_distance);
79 string RightOOBReadMessage(int oob_distance);
80 string LeftOOBErrorMessage(int oob_distance, bool is_write);
81 string LeftOOBWriteMessage(int oob_distance);
82 string LeftOOBReadMessage(int oob_distance);
83 string LeftOOBAccessMessage(int oob_distance);
84 char* MallocAndMemsetString(size_t size, char ch);
85 char* MallocAndMemsetString(size_t size);
96 extern char glob10[10];
97 extern char glob11[11];
98 extern char glob12[12];
99 extern char glob13[13];
100 extern char glob14[14];
101 extern char glob15[15];
102 extern char glob16[16];
103 extern char glob17[17];
104 extern char glob1000[1000];
105 extern char glob10000[10000];
106 extern char glob100000[100000];
107 extern int GlobalsTest(int x);
109 #endif // ASAN_TEST_UTILS_H