Sergey Matveev | 3bc65b1 | 2013-05-21 12:49:33 +0000 | [diff] [blame^] | 1 | //===-- lsan_testlib.cc ---------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file is a part of LeakSanitizer. |
| 11 | // Standalone LSan tool as a shared library, to be used with LD_PRELOAD. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | /* Usage: |
| 15 | clang++ ../sanitizer_common/sanitizer_*.cc ../interception/interception_*.cc \ |
| 16 | lsan*.cc tests/lsan_testlib.cc -I. -I.. -g -ldl -lpthread -fPIC -shared -O2 \ |
| 17 | -o lsan.so |
| 18 | LD_PRELOAD=./lsan.so /your/app |
| 19 | */ |
| 20 | #include "lsan_common.h" |
| 21 | #include "lsan.h" |
| 22 | |
| 23 | __attribute__((constructor)) |
| 24 | void constructor() { |
| 25 | __lsan::Init(); |
| 26 | } |
| 27 | |
| 28 | __attribute__((destructor)) |
| 29 | void destructor() { |
| 30 | __lsan::DoLeakCheck(); |
| 31 | } |