Chromium Code Reviews| 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) |