[Lldb-commits] [lldb] r201117 - Adjust the calls to __introspection_dispatch_thread_get_item_info to

Jason Molenda jmolenda at apple.com
Mon Feb 10 16:36:18 PST 2014


Author: jmolenda
Date: Mon Feb 10 18:36:18 2014
New Revision: 201117

URL: http://llvm.org/viewvc/llvm-project?rev=201117&view=rev
Log:
Adjust the calls to __introspection_dispatch_thread_get_item_info to
use a system-wide unique thread ID instead of a pthread_t to identify
the thread we want debug info for.  Also, free some more memory regions
that needed to be freed.

Modified:
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h
    lldb/trunk/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp

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=201117&r1=201116&r2=201117&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp Mon Feb 10 18:36:18 2014
@@ -67,7 +67,7 @@ extern \"C\"
     typedef void *introspection_dispatch_queue_info_t;                                                          \n\
     typedef void *introspection_dispatch_item_info_ref;                                                         \n\
                                                                                                                 \n\
-    extern void __introspection_dispatch_thread_get_item_info (pthread_t thread,                                \n\
+    extern void __introspection_dispatch_thread_get_item_info (uint64_t  thread_id,                             \n\
                                                  introspection_dispatch_item_info_ref *returned_queues_buffer,  \n\
                                                  uint64_t *returned_queues_buffer_size);                        \n\
                                                                                                                 \n\
@@ -84,18 +84,19 @@ extern \"C\"
     void  __lldb_backtrace_recording_get_thread_item_info                                                          \n\
                                                (struct get_thread_item_info_return_values *return_buffer,          \n\
                                                 int debug,                                                      \n\
+                                                uint64_t thread_id,                                             \n\
                                                 void *page_to_free,                                             \n\
                                                 uint64_t page_to_free_size)                                     \n\
 {                                                                                                               \n\
     void *pthread_id = pthread_self ();                                                                         \n\
     if (debug)                                                                                                  \n\
-      printf (\"entering get_thread_item_info with args return_buffer == %p, debug == %d, pthread id == 0x%llx, page_to_free == %p, page_to_free_size == 0x%llx\\n\", return_buffer, debug, (uint64_t) pthread_id, page_to_free, page_to_free_size); \n\
+      printf (\"entering get_thread_item_info with args return_buffer == %p, debug == %d, thread id == 0x%llx, page_to_free == %p, page_to_free_size == 0x%llx\\n\", return_buffer, debug, (uint64_t) thread_id, page_to_free, page_to_free_size); \n\
     if (page_to_free != 0)                                                                                      \n\
     {                                                                                                           \n\
         mach_vm_deallocate (mach_task_self(), (mach_vm_address_t) page_to_free, (mach_vm_size_t) page_to_free_size); \n\
     }                                                                                                           \n\
                                                                                                                 \n\
-    __introspection_dispatch_thread_get_item_info (pthread_id,                                                  \n\
+    __introspection_dispatch_thread_get_item_info (thread_id,                                                  \n\
                                                   (void**)&return_buffer->item_info_buffer_ptr,                 \n\
                                                   &return_buffer->item_info_buffer_size);                       \n\
 }                                                                                                               \n\
@@ -257,7 +258,7 @@ AppleGetThreadItemInfoHandler::SetupGetT
 }
 
 AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo
-AppleGetThreadItemInfoHandler::GetThreadItemInfo (Thread &thread, addr_t page_to_free, uint64_t page_to_free_size, Error &error)
+AppleGetThreadItemInfoHandler::GetThreadItemInfo (Thread &thread, tid_t thread_id, addr_t page_to_free, uint64_t page_to_free_size, Error &error)
 {
     lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0);
     ProcessSP process_sp (thread.CalculateProcess());
@@ -298,11 +299,15 @@ AppleGetThreadItemInfoHandler::GetThread
     debug_value.SetValueType (Value::eValueTypeScalar);
     debug_value.SetClangType (clang_int_type);
 
+    ClangASTType clang_uint64_type = clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong);
+    Value thread_id_value;
+    thread_id_value.SetValueType (Value::eValueTypeScalar);
+    thread_id_value.SetClangType (clang_uint64_type);
+
     Value page_to_free_value;
     page_to_free_value.SetValueType (Value::eValueTypeScalar);
     page_to_free_value.SetClangType (clang_void_ptr_type);
 
-    ClangASTType clang_uint64_type = clang_ast_context->GetBasicType(eBasicTypeUnsignedLongLong);
     Value page_to_free_size_value;
     page_to_free_size_value.SetValueType (Value::eValueTypeScalar);
     page_to_free_size_value.SetClangType (clang_uint64_type);
@@ -329,6 +334,9 @@ AppleGetThreadItemInfoHandler::GetThread
     debug_value.GetScalar() = 0;
     argument_values.PushValue (debug_value);
 
+    thread_id_value.GetScalar() = thread_id;
+    argument_values.PushValue (thread_id_value);
+
     if (page_to_free != LLDB_INVALID_ADDRESS)
         page_to_free_value.GetScalar() = page_to_free;
     else

Modified: lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h?rev=201117&r1=201116&r2=201117&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h Mon Feb 10 18:36:18 2014
@@ -67,8 +67,8 @@ public:
     /// memory that needs to be freed, pass in the address and size and it will
     /// be freed before getting the list of queues.
     ///
-    /// @param [in] thread
-    ///     The thread to run this plan on.
+    /// @param [in] thread_id
+    ///     The thread to get the extended backtrace for.
     ///
     /// @param [in] page_to_free
     ///     An address of an inferior process vm page that needs to be deallocated,
@@ -86,7 +86,7 @@ public:
     ///     the information, the item_buffer_ptr value will be LLDB_INVALID_ADDRESS.
     //----------------------------------------------------------
     GetThreadItemInfoReturnInfo
-    GetThreadItemInfo (Thread &thread, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Error &error);
+    GetThreadItemInfo (Thread &thread, lldb::tid_t thread_id, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Error &error);
 
 
     void

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=201117&r1=201116&r2=201117&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp Mon Feb 10 18:36:18 2014
@@ -277,7 +277,8 @@ SystemRuntimeMacOSX::GetExtendedBacktrac
         }
         else
         {
-            AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo ret = m_get_thread_item_info_handler.GetThreadItemInfo (*real_thread.get(), m_page_to_free, m_page_to_free_size, error);
+            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);
             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);
@@ -298,6 +299,8 @@ SystemRuntimeMacOSX::GetExtendedBacktrac
                     originating_thread_sp->SetQueueID (item.enqueuing_queue_serialnum);
 //                    originating_thread_sp->SetThreadName (item.enqueuing_thread_label.c_str());
                 }
+                m_page_to_free = ret.item_buffer_ptr;
+                m_page_to_free_size = ret.item_buffer_size;
             }
         }
     }
@@ -333,6 +336,8 @@ SystemRuntimeMacOSX::GetExtendedBacktrac
             return_thread_sp->SetQueueID (item.enqueuing_queue_serialnum);
 //            return_thread_sp->SetThreadName (item.enqueuing_thread_label.c_str());
 
+            m_page_to_free = ret.item_buffer_ptr;
+            m_page_to_free_size = ret.item_buffer_size;
         }
     }
     return return_thread_sp;
@@ -555,6 +560,8 @@ SystemRuntimeMacOSX::PopulatePendingItem
 
                     queue->PushPendingQueueItem (queue_item_sp);
                 }
+                m_page_to_free = ret.item_buffer_ptr;
+                m_page_to_free_size = ret.item_buffer_size;
             }
         }
     }





More information about the lldb-commits mailing list