2010-03-15 05:57:55 +01:00
|
|
|
//===-- Valgrind.cpp - Implement Valgrind communication ---------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Defines Valgrind communication methods, if HAVE_VALGRIND_VALGRIND_H is
|
|
|
|
// defined. If we have valgrind.h but valgrind isn't running, its macros are
|
|
|
|
// no-ops.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-11-29 19:16:10 +01:00
|
|
|
#include "llvm/Support/Valgrind.h"
|
2010-03-15 05:57:55 +01:00
|
|
|
#include "llvm/Config/config.h"
|
|
|
|
|
|
|
|
#if HAVE_VALGRIND_VALGRIND_H
|
|
|
|
#include <valgrind/valgrind.h>
|
|
|
|
|
|
|
|
static bool InitNotUnderValgrind() {
|
|
|
|
return !RUNNING_ON_VALGRIND;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This bool is negated from what we'd expect because code may run before it
|
|
|
|
// gets initialized. If that happens, it will appear to be 0 (false), and we
|
|
|
|
// want that to cause the rest of the code in this file to run the
|
|
|
|
// Valgrind-provided macros.
|
|
|
|
static const bool NotUnderValgrind = InitNotUnderValgrind();
|
|
|
|
|
|
|
|
bool llvm::sys::RunningOnValgrind() {
|
|
|
|
if (NotUnderValgrind)
|
|
|
|
return false;
|
|
|
|
return RUNNING_ON_VALGRIND;
|
|
|
|
}
|
|
|
|
|
|
|
|
void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {
|
|
|
|
if (NotUnderValgrind)
|
|
|
|
return;
|
|
|
|
|
2011-07-02 15:14:22 +02:00
|
|
|
VALGRIND_DISCARD_TRANSLATIONS(Addr, Len);
|
2010-03-15 05:57:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else // !HAVE_VALGRIND_VALGRIND_H
|
|
|
|
|
|
|
|
bool llvm::sys::RunningOnValgrind() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) {
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // !HAVE_VALGRIND_VALGRIND_H
|
2011-11-14 21:50:16 +01:00
|
|
|
|
2011-11-28 23:14:02 +01:00
|
|
|
#if LLVM_ENABLE_THREADS != 0 && !defined(NDEBUG)
|
2011-11-14 21:50:16 +01:00
|
|
|
// These functions require no implementation, tsan just looks at the arguments
|
|
|
|
// they're called with.
|
|
|
|
extern "C" {
|
2011-11-15 02:23:22 +01:00
|
|
|
void AnnotateHappensBefore(const char *file, int line,
|
|
|
|
const volatile void *cv) {}
|
|
|
|
void AnnotateHappensAfter(const char *file, int line,
|
|
|
|
const volatile void *cv) {}
|
|
|
|
void AnnotateIgnoreWritesBegin(const char *file, int line) {}
|
|
|
|
void AnnotateIgnoreWritesEnd(const char *file, int line) {}
|
2011-11-14 21:50:16 +01:00
|
|
|
}
|
2011-11-28 23:14:02 +01:00
|
|
|
#endif
|