[ARM/AArch64][testsuite] Add vsubhn, vraddhn and vrsubhn tests. Split vaddhn.c into...
[official-gcc.git] / libsanitizer / asan / asan_activation.cc
blob235451c8aec24d45672d1b7a9832e6003f7c3129
1 //===-- asan_activation.cc --------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // ASan activation/deactivation logic.
11 //===----------------------------------------------------------------------===//
13 #include "asan_activation.h"
14 #include "asan_allocator.h"
15 #include "asan_flags.h"
16 #include "asan_internal.h"
17 #include "sanitizer_common/sanitizer_flags.h"
19 namespace __asan {
21 static struct AsanDeactivatedFlags {
22 int quarantine_size;
23 int max_redzone;
24 int malloc_context_size;
25 bool poison_heap;
26 } asan_deactivated_flags;
28 static bool asan_is_deactivated;
30 void AsanStartDeactivated() {
31 VReport(1, "Deactivating ASan\n");
32 // Save flag values.
33 asan_deactivated_flags.quarantine_size = flags()->quarantine_size;
34 asan_deactivated_flags.max_redzone = flags()->max_redzone;
35 asan_deactivated_flags.poison_heap = flags()->poison_heap;
36 asan_deactivated_flags.malloc_context_size =
37 common_flags()->malloc_context_size;
39 flags()->quarantine_size = 0;
40 flags()->max_redzone = 16;
41 flags()->poison_heap = false;
42 common_flags()->malloc_context_size = 0;
44 asan_is_deactivated = true;
47 void AsanActivate() {
48 if (!asan_is_deactivated) return;
49 VReport(1, "Activating ASan\n");
51 // Restore flag values.
52 // FIXME: this is not atomic, and there may be other threads alive.
53 flags()->quarantine_size = asan_deactivated_flags.quarantine_size;
54 flags()->max_redzone = asan_deactivated_flags.max_redzone;
55 flags()->poison_heap = asan_deactivated_flags.poison_heap;
56 common_flags()->malloc_context_size =
57 asan_deactivated_flags.malloc_context_size;
59 ParseExtraActivationFlags();
61 ReInitializeAllocator();
63 asan_is_deactivated = false;
64 VReport(
66 "quarantine_size %d, max_redzone %d, poison_heap %d, malloc_context_size "
67 "%d\n",
68 flags()->quarantine_size, flags()->max_redzone, flags()->poison_heap,
69 common_flags()->malloc_context_size);
72 } // namespace __asan