[Lldb-commits] [lldb] r149136 - /lldb/trunk/include/lldb/Utility/SharingPtr.h

Greg Clayton gclayton at apple.com
Fri Jan 27 10:33:53 PST 2012


Author: gclayton
Date: Fri Jan 27 12:33:53 2012
New Revision: 149136

URL: http://llvm.org/viewvc/llvm-project?rev=149136&view=rev
Log:
NULL out the "ptr_" member of shared pointers for debug and release
builds (not build and integration builds) to help catch when a shared pointer
that might be in a collection class is used after the collection
has been freed.


Modified:
    lldb/trunk/include/lldb/Utility/SharingPtr.h

Modified: lldb/trunk/include/lldb/Utility/SharingPtr.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharingPtr.h?rev=149136&r1=149135&r2=149136&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/SharingPtr.h (original)
+++ lldb/trunk/include/lldb/Utility/SharingPtr.h Fri Jan 27 12:33:53 2012
@@ -684,6 +684,15 @@
     ~IntrusiveSharingPtr() 
     {
         release_shared(); 
+#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
+        // NULL out the pointer in objects which can help with leaks detection.
+        // We don't enable this for LLDB_CONFIGURATION_BUILD_AND_INTEGRATION or
+        // when none of the LLDB_CONFIGURATION_XXX macros are defined since
+        // those would be builds for release. But for debug and release builds
+        // that are for development, we NULL out the pointers to catch potential
+        // issues.
+        ptr_ = NULL; 
+#endif  // #if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
     }
     
     T& 





More information about the lldb-commits mailing list