|
|
|
@ -12,62 +12,78 @@ |
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
bool BuiltUnderValgrind() { |
|
|
|
|
#ifdef RUNNING_ON_VALGRIND |
|
|
|
|
return true; |
|
|
|
|
#else |
|
|
|
|
return false; |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool BuiltUnderTsan() { |
|
|
|
|
// Define GRPC_BUILD_HAS_ASAN as 1 or 0 depending on if we're building under
|
|
|
|
|
// ASAN.
|
|
|
|
|
#if defined(__has_feature) |
|
|
|
|
#if __has_feature(thread_sanitizer) |
|
|
|
|
return true; |
|
|
|
|
#if __has_feature(address_sanitizer) |
|
|
|
|
#define GRPC_BUILD_HAS_ASAN 1 |
|
|
|
|
#else |
|
|
|
|
return false; |
|
|
|
|
#define GRPC_BUILD_HAS_ASAN 0 |
|
|
|
|
#endif |
|
|
|
|
#else |
|
|
|
|
#ifdef THREAD_SANITIZER |
|
|
|
|
return true; |
|
|
|
|
#ifdef ADDRESS_SANITIZER |
|
|
|
|
#define GRPC_BUILD_HAS_ASAN 1 |
|
|
|
|
#else |
|
|
|
|
return false; |
|
|
|
|
#define GRPC_BUILD_HAS_ASAN 0 |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool BuiltUnderAsan() { |
|
|
|
|
// Define GRPC_BUILD_HAS_TSAN as 1 or 0 depending on if we're building under
|
|
|
|
|
// TSAN.
|
|
|
|
|
#if defined(__has_feature) |
|
|
|
|
#if __has_feature(address_sanitizer) |
|
|
|
|
return true; |
|
|
|
|
#if __has_feature(thread_sanitizer) |
|
|
|
|
#define GRPC_BUILD_HAS_TSAN 1 |
|
|
|
|
#else |
|
|
|
|
return false; |
|
|
|
|
#define GRPC_BUILD_HAS_TSAN 0 |
|
|
|
|
#endif |
|
|
|
|
#else |
|
|
|
|
#ifdef ADDRESS_SANITIZER |
|
|
|
|
return true; |
|
|
|
|
#ifdef THREAD_SANITIZER |
|
|
|
|
#define GRPC_BUILD_HAS_TSAN 1 |
|
|
|
|
#else |
|
|
|
|
return false; |
|
|
|
|
#define GRPC_BUILD_HAS_TSAN 0 |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool BuiltUnderMsan() { |
|
|
|
|
// Define GRPC_BUILD_HAS_MSAN as 1 or 0 depending on if we're building under
|
|
|
|
|
// MSAN.
|
|
|
|
|
#if defined(__has_feature) |
|
|
|
|
#if __has_feature(memory_sanitizer) |
|
|
|
|
return true; |
|
|
|
|
#define GRPC_BUILD_HAS_MSAN 1 |
|
|
|
|
#else |
|
|
|
|
return false; |
|
|
|
|
#define GRPC_BUILD_HAS_MSAN 0 |
|
|
|
|
#endif |
|
|
|
|
#else |
|
|
|
|
#ifdef MEMORY_SANITIZER |
|
|
|
|
#define GRPC_BUILD_HAS_MSAN 1 |
|
|
|
|
#else |
|
|
|
|
#define GRPC_BUILD_HAS_MSAN 0 |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if GRPC_BUILD_HAS_ASAN |
|
|
|
|
#include <sanitizer/lsan_interface.h> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
bool BuiltUnderValgrind() { |
|
|
|
|
#ifdef RUNNING_ON_VALGRIND |
|
|
|
|
return true; |
|
|
|
|
#else |
|
|
|
|
return false; |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool BuiltUnderTsan() { return GRPC_BUILD_HAS_TSAN != 0; } |
|
|
|
|
|
|
|
|
|
bool BuiltUnderAsan() { return GRPC_BUILD_HAS_ASAN != 0; } |
|
|
|
|
|
|
|
|
|
void AsanAssertNoLeaks() { |
|
|
|
|
#if GRPC_BUILD_HAS_ASAN |
|
|
|
|
__lsan_do_leak_check(); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool BuiltUnderMsan() { return GRPC_BUILD_HAS_MSAN != 0; } |
|
|
|
|
|
|
|
|
|
bool BuiltUnderUbsan() { |
|
|
|
|
#ifdef GRPC_UBSAN |
|
|
|
|
return true; |
|
|
|
|