Valgrind.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // Defines Valgrind communication methods, if HAVE_VALGRIND_VALGRIND_H is
  10. // defined. If we have valgrind.h but valgrind isn't running, its macros are
  11. // no-ops.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #include <stddef.h>
  15. #include "llvm/Support/Valgrind.h"
  16. #include "llvm/Config/config.h"
  17. #if HAVE_VALGRIND_VALGRIND_H
  18. #include <valgrind/valgrind.h>
  19. bool llvm::sys::RunningOnValgrind() {
  20. return RUNNING_ON_VALGRIND;
  21. }
  22. void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {
  23. VALGRIND_DISCARD_TRANSLATIONS(Addr, Len);
  24. }
  25. #else // !HAVE_VALGRIND_VALGRIND_H
  26. bool llvm::sys::RunningOnValgrind() {
  27. return false;
  28. }
  29. void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {
  30. }
  31. #endif // !HAVE_VALGRIND_VALGRIND_H