Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1163)

Unified Diff: base/debug/leak_annotations.h

Issue 15652009: Add LeakSanitizer annotations to base/debug/leak_annotations.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/leak_annotations.h
diff --git a/base/debug/leak_annotations.h b/base/debug/leak_annotations.h
index 51adfb05d6c7b22c1604a52357f95cf8bdae6617..78e93e5200267311cc1e37e58bbe4bcf6edbcc5e 100644
--- a/base/debug/leak_annotations.h
+++ b/base/debug/leak_annotations.h
@@ -29,9 +29,39 @@
#define ANNOTATE_LEAKING_OBJECT_PTR(X) \
HeapLeakChecker::IgnoreObject(X)
+#elif defined(LEAK_SANITIZER)
+
+// LeakSanitizer supports the same annotations as HeapChecker above.
+// Beware that LeakSanitizer does not report a fatal error when an object is
+// annotated twice, or an annotated object is deleted. This can be a source of
+// discrepancy between LSan and HeapChecker builds.
+
+extern "C" {
+void __lsan_disable();
+void __lsan_enable();
+void __lsan_ignore_object(const void *p);
+} // extern "C"
+
+namespace __lsan {
+class ScopedLeakSanitizerDisabler {
+ public:
+ ScopedLeakSanitizerDisabler() { __lsan_disable(); }
+ ~ScopedLeakSanitizerDisabler() { __lsan_enable(); }
+ private:
+ // Disallow copy and assign.
+ ScopedLeakSanitizerDisabler(const ScopedLeakSanitizerDisabler&);
jar (doing other things) 2013/06/12 18:43:59 explicit?
+ void operator=(const ScopedLeakSanitizerDisabler&);
+};
+} // namespace __lsan
+
+#define ANNOTATE_SCOPED_MEMORY_LEAK \
+ __lsan::ScopedLeakSanitizerDisabler leak_sanitizer_disabler
+
+#define ANNOTATE_LEAKING_OBJECT_PTR(X) __lsan_ignore_object(X);
+
#else
-// If tcmalloc is not used, the annotations should be no-ops.
+// If neither HeapChecker nor LSan are used, the annotations should be no-ops.
#define ANNOTATE_SCOPED_MEMORY_LEAK ((void)0)
#define ANNOTATE_LEAKING_OBJECT_PTR(X) ((void)0)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698