Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: syzygy/integration_tests/asan_interceptors_tests.h

Issue 2983783002: Run the integration tests against the Clang instrumented DLL. (Closed)
Patch Set: Address Chris comment. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | syzygy/integration_tests/asan_interceptors_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 Google Inc. All Rights Reserved. 1 // Copyright 2013 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 13 matching lines...) Expand all
24 namespace testing { 24 namespace testing {
25 25
26 // Disable the intrinsic versions of the intercepted functions. 26 // Disable the intrinsic versions of the intercepted functions.
27 #pragma function(memset, memcpy, strlen, strcmp) 27 #pragma function(memset, memcpy, strlen, strcmp)
28 28
29 // Helper function to make sure that a memory read access doesn't get 29 // Helper function to make sure that a memory read access doesn't get
30 // instrumented. 30 // instrumented.
31 // @tparam type The type of the value to be read. 31 // @tparam type The type of the value to be read.
32 // @param location The location where to read from. 32 // @param location The location where to read from.
33 // @returns the value at |location| 33 // @returns the value at |location|
34 template<typename type> 34 template <typename type>
35 #if defined(__clang__)
36 type __attribute__((no_sanitize_address)) NonInterceptedRead(type* location) {
37 return *location;
38 }
39 #else
35 type NonInterceptedRead(type* location) { 40 type NonInterceptedRead(type* location) {
36 // The try-except statement prevents the function from being instrumented. 41 // The try-except statement prevents the function from being instrumented.
37 __try { 42 __try {
38 return *location; 43 return *location;
39 } __except(EXCEPTION_CONTINUE_SEARCH) { 44 } __except(EXCEPTION_CONTINUE_SEARCH) {
40 // Nothing to do here. 45 // Nothing to do here.
41 } 46 }
42 return static_cast<type>(0); 47 return static_cast<type>(0);
43 } 48 }
49 #endif
44 50
45 // Helper function to do non instrumented reads from an array. 51 // Helper function to do non instrumented reads from an array.
46 // @tparam type The type of the values to be read. 52 // @tparam type The type of the values to be read.
47 // @param src The array where to read from. 53 // @param src The array where to read from.
48 // @param size The size of the array. 54 // @param size The size of the array.
49 // @param dst The destination array. 55 // @param dst The destination array.
50 template<typename type> 56 template<typename type>
51 void NonInterceptedReads(type* src, size_t size, type* dst) { 57 void NonInterceptedReads(type* src, size_t size, type* dst) {
52 for (size_t i = 0; i < size; ++i) 58 for (size_t i = 0; i < size; ++i)
53 *dst++ = NonInterceptedRead(src + i); 59 *dst++ = NonInterceptedRead(src + i);
54 } 60 }
55 61
56 // Helper function to make sure that a memory write access didn't get 62 // Helper function to make sure that a memory write access didn't get
57 // instrumented. 63 // instrumented.
58 // @tparam type The type of the value to be written. 64 // @tparam type The type of the value to be written.
59 // @param location The location where to write to. 65 // @param location The location where to write to.
60 // @param val The value to write. 66 // @param val The value to write.
61 template<typename type> 67 template <typename type>
68 #if defined(__clang__)
69 void __attribute__((no_sanitize_address))
70 NonInterceptedWrite(type* location, type val) {
71 *location = val;
72 }
73 #else
62 void NonInterceptedWrite(type* location, type val) { 74 void NonInterceptedWrite(type* location, type val) {
63 // The try-except statement prevents the function from being instrumented. 75 // The try-except statement prevents the function from being instrumented.
64 __try { 76 __try {
65 *location = val; 77 *location = val;
66 } __except(EXCEPTION_CONTINUE_SEARCH) { 78 } __except(EXCEPTION_CONTINUE_SEARCH) {
67 // Nothing to do here. 79 // Nothing to do here.
68 } 80 }
69 } 81 }
82 #endif
70 83
71 // Helper function to do non instrumented writes from an array. 84 // Helper function to do non instrumented writes from an array.
72 // @tparam type The type of the values to be written. 85 // @tparam type The type of the values to be written.
73 // @param src The array where to read from. 86 // @param src The array where to read from.
74 // @param size The size of the array. 87 // @param size The size of the array.
75 // @param dst The address where to write to. 88 // @param dst The address where to write to.
76 template<typename type> 89 template<typename type>
77 void NonInterceptedWrites(type* src, size_t size, type* dst) { 90 void NonInterceptedWrites(type* src, size_t size, type* dst) {
78 for (size_t i = 0; i < size; ++i) 91 for (size_t i = 0; i < size; ++i)
79 NonInterceptedWrite(dst++, src[i]); 92 NonInterceptedWrite(dst++, src[i]);
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 // "uninstrumented" tests will cause an access violation exception to be thrown. 473 // "uninstrumented" tests will cause an access violation exception to be thrown.
461 size_t AsanNearNullptrAccessHeapCorruptionInstrumented(); 474 size_t AsanNearNullptrAccessHeapCorruptionInstrumented();
462 size_t AsanNearNullptrAccessHeapCorruptionUninstrumented(); 475 size_t AsanNearNullptrAccessHeapCorruptionUninstrumented();
463 size_t AsanNearNullptrAccessNoHeapCorruptionInstrumented(); 476 size_t AsanNearNullptrAccessNoHeapCorruptionInstrumented();
464 size_t AsanNearNullptrAccessNoHeapCorruptionUninstrumented(); 477 size_t AsanNearNullptrAccessNoHeapCorruptionUninstrumented();
465 size_t AsanNullptrAccessNoHeapCorruptionUninstrumented(); 478 size_t AsanNullptrAccessNoHeapCorruptionUninstrumented();
466 479
467 } // namespace testing 480 } // namespace testing
468 481
469 #endif // SYZYGY_INTEGRATION_TESTS_ASAN_INTERCEPTORS_TESTS_H_ 482 #endif // SYZYGY_INTEGRATION_TESTS_ASAN_INTERCEPTORS_TESTS_H_
OLDNEW
« no previous file with comments | « no previous file | syzygy/integration_tests/asan_interceptors_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698