[Lldb-commits] [lldb] r201447 - Add some additional logging to the Mac OS X SystemRuntime. Fix a bug where lldb could free an inferior's vm_page.

Jason Molenda jmolenda at apple.com
Fri Feb 14 16:20:41 PST 2014


Author: jmolenda
Date: Fri Feb 14 18:20:40 2014
New Revision: 201447

URL: http://llvm.org/viewvc/llvm-project?rev=201447&view=rev
Log:
Add some additional logging to the Mac OS X SystemRuntime.  Fix a bug where lldb could free an inferior's vm_page.

Modified:
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp

Modified: lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp?rev=201447&r1=201446&r2=201447&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp Fri Feb 14 18:20:40 2014
@@ -385,6 +385,9 @@ AppleGetItemInfoHandler::GetItemInfo (Th
         return_value.item_buffer_ptr = LLDB_INVALID_ADDRESS;
         return return_value;
     }
+    if (log)
+        log->Printf ("AppleGetItemInfoHandler called __introspection_dispatch_queue_item_get_info (page_to_free == 0x%" PRIx64 ", size = %" PRId64 "), returned page is at 0x%" PRIx64 ", size %" PRId64, page_to_free, page_to_free_size, return_value.item_buffer_ptr, return_value.item_buffer_size);
+
 
     return return_value;
 }

Modified: lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp?rev=201447&r1=201446&r2=201447&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp Fri Feb 14 18:20:40 2014
@@ -398,5 +398,8 @@ AppleGetPendingItemsHandler::GetPendingI
         return return_value;
     }
 
+    if (log)
+        log->Printf ("AppleGetPendingItemsHandler called __introspection_dispatch_queue_get_pending_items (page_to_free == 0x%" PRIx64 ", size = %" PRId64 "), returned page is at 0x%" PRIx64 ", size %" PRId64 ", count = %" PRId64, page_to_free, page_to_free_size, return_value.items_buffer_ptr, return_value.items_buffer_ptr, return_value.count);
+
     return return_value;
 }

Modified: lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp?rev=201447&r1=201446&r2=201447&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp Fri Feb 14 18:20:40 2014
@@ -397,5 +397,8 @@ AppleGetQueuesHandler::GetCurrentQueues
         return return_value;
     }
 
+    if (log)
+        log->Printf ("AppleGetQueuesHandler called __introspection_dispatch_get_queues (page_to_free == 0x%" PRIx64 ", size = %" PRId64 "), returned page is at 0x%" PRIx64 ", size %" PRId64 ", count = %" PRId64, page_to_free, page_to_free_size, return_value.queues_buffer_ptr, return_value.queues_buffer_size, return_value.count);
+
     return return_value;
 }

Modified: lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp?rev=201447&r1=201446&r2=201447&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp Fri Feb 14 18:20:40 2014
@@ -389,5 +389,8 @@ AppleGetThreadItemInfoHandler::GetThread
         return return_value;
     }
 
+    if (log)
+        log->Printf ("AppleGetThreadItemInfoHandler called __introspection_dispatch_thread_get_item_info (page_to_free == 0x%" PRIx64 ", size = %" PRId64 "), returned page is at 0x%" PRIx64 ", size %" PRId64, page_to_free, page_to_free_size, return_value.item_buffer_ptr, return_value.item_buffer_size);
+
     return return_value;
 }

Modified: lldb/trunk/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp?rev=201447&r1=201446&r2=201447&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp Fri Feb 14 18:20:40 2014
@@ -279,6 +279,8 @@ SystemRuntimeMacOSX::GetExtendedBacktrac
         {
             ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread());
             AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo ret = m_get_thread_item_info_handler.GetThreadItemInfo (*cur_thread_sp.get(), real_thread->GetID(), m_page_to_free, m_page_to_free_size, error);
+            m_page_to_free = LLDB_INVALID_ADDRESS;
+            m_page_to_free_size = 0;
             if (ret.item_buffer_ptr != 0 &&  ret.item_buffer_ptr != LLDB_INVALID_ADDRESS && ret.item_buffer_size > 0)
             {
                 DataBufferHeap data (ret.item_buffer_size, 0);
@@ -316,6 +318,8 @@ SystemRuntimeMacOSX::GetExtendedBacktrac
     ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread());
     Error error;
     ret = m_get_item_info_handler.GetItemInfo (*cur_thread_sp.get(), item_ref, m_page_to_free, m_page_to_free_size, error);
+    m_page_to_free = LLDB_INVALID_ADDRESS;
+    m_page_to_free_size = 0;
     if (ret.item_buffer_ptr != 0 &&  ret.item_buffer_ptr != LLDB_INVALID_ADDRESS && ret.item_buffer_size > 0)
     {
         DataBufferHeap data (ret.item_buffer_size, 0);
@@ -505,10 +509,10 @@ SystemRuntimeMacOSX::PopulateQueueList (
         { 
             Error error;
             queue_info_pointer = m_get_queues_handler.GetCurrentQueues (*cur_thread_sp.get(), m_page_to_free, m_page_to_free_size, error);
+            m_page_to_free = LLDB_INVALID_ADDRESS;
+            m_page_to_free_size = 0;
             if (error.Success())
             {
-                m_page_to_free = LLDB_INVALID_ADDRESS;
-                m_page_to_free_size = 0;
 
                 if (queue_info_pointer.count > 0 
                     && queue_info_pointer.queues_buffer_size > 0
@@ -534,6 +538,8 @@ SystemRuntimeMacOSX::PopulatePendingItem
             ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread());
             Error error;
             ret = m_get_item_info_handler.GetItemInfo (*cur_thread_sp.get(), pending_item, m_page_to_free, m_page_to_free_size, error);
+            m_page_to_free = LLDB_INVALID_ADDRESS;
+            m_page_to_free_size = 0;
             if (ret.item_buffer_ptr != 0 &&  ret.item_buffer_ptr != LLDB_INVALID_ADDRESS && ret.item_buffer_size > 0)
             {
                 DataBufferHeap data (ret.item_buffer_size, 0);
@@ -560,8 +566,6 @@ SystemRuntimeMacOSX::PopulatePendingItem
 
                     queue->PushPendingQueueItem (queue_item_sp);
                 }
-                m_page_to_free = ret.item_buffer_ptr;
-                m_page_to_free_size = ret.item_buffer_size;
             }
         }
     }
@@ -581,10 +585,10 @@ SystemRuntimeMacOSX::GetPendingItemRefsF
     { 
         Error error;
         pending_items_pointer = m_get_pending_items_handler.GetPendingItems (*cur_thread_sp.get(), queue, m_page_to_free, m_page_to_free_size, error);
+        m_page_to_free = LLDB_INVALID_ADDRESS;
+        m_page_to_free_size = 0;
         if (error.Success())
         {
-            m_page_to_free = LLDB_INVALID_ADDRESS;
-            m_page_to_free_size = 0;
             if (pending_items_pointer.count > 0
                 && pending_items_pointer.items_buffer_size > 0
                 && pending_items_pointer.items_buffer_ptr != 0





More information about the lldb-commits mailing list