[Lldb-commits] [lldb] r156506 - in /lldb/branches/apple/python-GIL: ./ source/Core/ConstString.cpp test/redo.py

Filipe Cabecinhas me at filcab.net
Wed May 9 12:08:04 PDT 2012


Author: filcab
Date: Wed May  9 14:08:04 2012
New Revision: 156506

URL: http://llvm.org/viewvc/llvm-project?rev=156506&view=rev
Log:
Merged /lldb/trunk:r156469-156504

Modified:
    lldb/branches/apple/python-GIL/   (props changed)
    lldb/branches/apple/python-GIL/source/Core/ConstString.cpp
    lldb/branches/apple/python-GIL/test/redo.py

Propchange: lldb/branches/apple/python-GIL/
------------------------------------------------------------------------------
    svn:mergeinfo = /lldb/trunk:156469-156504

Modified: lldb/branches/apple/python-GIL/source/Core/ConstString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Core/ConstString.cpp?rev=156506&r1=156505&r2=156506&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Core/ConstString.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Core/ConstString.cpp Wed May  9 14:08:04 2012
@@ -167,12 +167,32 @@
 // initializers so we hide the string pool in a static function so
 // that it will get initialized on the first call to this static
 // function.
+//
+// Note, for now we make the string pool a pointer to the pool, because
+// we can't guarantee that some objects won't get destroyed after the
+// global destructor chain is run, and trying to make sure no destructors
+// touch ConstStrings is difficult.  So we leak the pool instead.
+//
+// FIXME: If we are going to keep it this way we should come up with some
+// abstraction to "pthread_once" so we don't have to check the pointer
+// every time.
 //----------------------------------------------------------------------
 static Pool &
 StringPool()
 {
-    static Pool string_pool;
-    return string_pool;
+    static Mutex g_pool_initialization_mutex;
+    static Pool *g_string_pool = NULL;
+
+    if (g_string_pool == NULL)
+    {
+        Mutex::Locker initialization_locker(g_pool_initialization_mutex);
+        if (g_string_pool == NULL)
+        {
+            g_string_pool = new Pool();
+        }
+    }
+    
+    return *g_string_pool;
 }
 
 ConstString::ConstString (const char *cstr) :

Modified: lldb/branches/apple/python-GIL/test/redo.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/test/redo.py?rev=156506&r1=156505&r2=156506&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/test/redo.py (original)
+++ lldb/branches/apple/python-GIL/test/redo.py Wed May  9 14:08:04 2012
@@ -117,6 +117,9 @@
         print "This script expects to reside in lldb's test directory."
         sys.exit(-1)
 
+    if not len(sys.argv) > 1:
+        usage()
+
     index = 1
     while index < len(sys.argv):
         if sys.argv[index].startswith('-h'):
@@ -135,10 +138,10 @@
             if index >= len(sys.argv) or sys.argv[index].startswith('-'):
                 usage()
             filename_components.append(sys.argv[index])
-            index += 1
         elif sys.argv[index] == '-n':
             no_trace = True
-            index += 1
+
+        index += 1
 
     if index < len(sys.argv):
         # Get the specified session directory.
@@ -147,6 +150,9 @@
         # Use heuristic to find the latest session directory.
         name = datetime.datetime.now().strftime("%Y-%m-%d-")
         dirs = [d for d in os.listdir(os.getcwd()) if d.startswith(name)]
+        if len(dirs) == 0:
+            print "No default session directory found, please specify it explicitly."
+            usage()
         session_dir = max(dirs, key=os.path.getmtime)
         if not session_dir or not os.path.exists(session_dir):
             print "No default session directory found, please specify it explicitly."





More information about the lldb-commits mailing list