40 lines · cpp
1//===-- Valgrind.cpp - Implement Valgrind communication ---------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// Defines Valgrind communication methods, if HAVE_VALGRIND_VALGRIND_H is10// defined. If we have valgrind.h but valgrind isn't running, its macros are11// no-ops.12//13//===----------------------------------------------------------------------===//14 15#include <stddef.h>16#include "llvm/Support/Valgrind.h"17#include "llvm/Config/config.h"18 19#if HAVE_VALGRIND_VALGRIND_H20#include <valgrind/valgrind.h>21 22bool llvm::sys::RunningOnValgrind() {23 return RUNNING_ON_VALGRIND;24}25 26void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {27 VALGRIND_DISCARD_TRANSLATIONS(Addr, Len);28}29 30#else // !HAVE_VALGRIND_VALGRIND_H31 32bool llvm::sys::RunningOnValgrind() {33 return false;34}35 36void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {37}38 39#endif // !HAVE_VALGRIND_VALGRIND_H40