[PATCH] LSan in LD_PRELOAD library form

Sergey Matveev earthdok at google.com
Tue May 21 05:01:27 PDT 2013


    - removed unnecessary declarations

Hi kcc, glider,

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

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D832?vs=2043&id=2048#toc

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,31 @@
+//===-- 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"
+
+__attribute__((constructor))
+void constructor() {
+  __lsan::Init();
+}
+
+__attribute__((destructor))
+void destructor() {
+  __lsan::DoLeakCheck();
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D832.2.patch
Type: text/x-patch
Size: 1149 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130521/e1e69f39/attachment.bin>


More information about the llvm-commits mailing list