[PATCH] LSan in LD_PRELOAD library form

Sergey Matveev earthdok at google.com
Mon May 20 10:27:10 PDT 2013


Hi kcc, glider,

http://llvm-reviews.chandlerc.com/D832

Files:
  lib/lsan/tests/lsan_testlib.cc

Index: lib/lsan/tests/lsan_testlib.cc
===================================================================
--- /dev/null
+++ lib/lsan/tests/lsan_testlib.cc
@@ -0,0 +1,33 @@
+//===-- lsan_testlib.cc ---------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of LeakSanitizer.
+// Standalone LSan tool as a shared library, to be used with LD_PRELOAD.
+//
+//===----------------------------------------------------------------------===//
+/* Usage:
+clang++ ../sanitizer_common/sanitizer_*.cc ../interception/interception_*.cc \
+ lsan*.cc tests/lsan_testlib.cc -I. -I.. -g -ldl -lpthread -fPIC -shared -O2 \
+ -o lsan.so
+LD_PRELOAD=./lsan.so /your/app
+*/
+#include "lsan_common.h"
+#include "lsan.h"
+
+static void constructor() __attribute__((constructor));
+
+void constructor() {
+  __lsan::Init();
+}
+
+static void destructor() __attribute__((destructor));
+
+void destructor() {
+  __lsan::DoLeakCheck();
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D832.1.patch
Type: text/x-patch
Size: 1206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130520/d5ec510e/attachment.bin>


More information about the llvm-commits mailing list