| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 #include "wtf/Noncopyable.h" | 50 #include "wtf/Noncopyable.h" |
| 51 | 51 |
| 52 namespace WTF { | 52 namespace WTF { |
| 53 | 53 |
| 54 #if USE(LEAK_SANITIZER) | 54 #if USE(LEAK_SANITIZER) |
| 55 extern "C" { | 55 extern "C" { |
| 56 void __lsan_disable(); | 56 void __lsan_disable(); |
| 57 void __lsan_enable(); | 57 void __lsan_enable(); |
| 58 void __lsan_ignore_object(const void* p); | 58 void __lsan_ignore_object(const void* p); |
| 59 } // extern "C" | 59 } // extern "C" |
| 60 | 60 |
| 61 class LeakSanitizerDisabler { | 61 class LeakSanitizerDisabler { |
| 62 WTF_MAKE_NONCOPYABLE(LeakSanitizerDisabler); | 62 WTF_MAKE_NONCOPYABLE(LeakSanitizerDisabler); |
| 63 public: | |
| 64 LeakSanitizerDisabler() | |
| 65 { | |
| 66 __lsan_disable(); | |
| 67 } | |
| 68 | 63 |
| 69 ~LeakSanitizerDisabler() | 64 public: |
| 70 { | 65 LeakSanitizerDisabler() { |
| 71 __lsan_enable(); | 66 __lsan_disable(); |
| 72 } | 67 } |
| 68 |
| 69 ~LeakSanitizerDisabler() { |
| 70 __lsan_enable(); |
| 71 } |
| 73 }; | 72 }; |
| 74 | 73 |
| 75 #define WTF_ANNOTATE_SCOPED_MEMORY_LEAK \ | 74 #define WTF_ANNOTATE_SCOPED_MEMORY_LEAK \ |
| 76 WTF::LeakSanitizerDisabler leakSanitizerDisabler; static_cast<void>(0) | 75 WTF::LeakSanitizerDisabler leakSanitizerDisabler; \ |
| 76 static_cast<void>(0) |
| 77 | 77 |
| 78 #define WTF_ANNOTATE_LEAKING_OBJECT_PTR(X) \ | 78 #define WTF_ANNOTATE_LEAKING_OBJECT_PTR(X) \ |
| 79 WTF::__lsan_ignore_object(X) | 79 WTF::__lsan_ignore_object(X) |
| 80 | 80 |
| 81 #else // USE(LEAK_SANITIZER) | 81 #else // USE(LEAK_SANITIZER) |
| 82 | 82 |
| 83 // If Leak Sanitizer is not being used, the annotations should be no-ops. | 83 // If Leak Sanitizer is not being used, the annotations should be no-ops. |
| 84 #define WTF_ANNOTATE_SCOPED_MEMORY_LEAK | 84 #define WTF_ANNOTATE_SCOPED_MEMORY_LEAK |
| 85 #define WTF_ANNOTATE_LEAKING_OBJECT_PTR(X) | 85 #define WTF_ANNOTATE_LEAKING_OBJECT_PTR(X) |
| 86 | 86 |
| 87 #endif // USE(LEAK_SANITIZER) | 87 #endif // USE(LEAK_SANITIZER) |
| 88 | 88 |
| 89 } // namespace WTF | 89 } // namespace WTF |
| 90 | 90 |
| 91 #endif // WTF_LeakAnnotations_h | 91 #endif // WTF_LeakAnnotations_h |
| OLD | NEW |