diff options
| author | Jason Molenda <jmolenda@apple.com> | 2014-05-13 22:02:48 +0000 |
|---|---|---|
| committer | Jason Molenda <jmolenda@apple.com> | 2014-05-13 22:02:48 +0000 |
| commit | b4892cd266dfafb9c6986ee46a8025c8031c3792 (patch) | |
| tree | 5b127dbb778899f9efbdd51026ef74edeceefbd1 /lldb/source/Plugins/SystemRuntime | |
| parent | 1b91aa2cf5141ee3dc4cbbf2e6bdb931b51411ff (diff) | |
| download | bcm5719-llvm-b4892cd266dfafb9c6986ee46a8025c8031c3792.tar.gz bcm5719-llvm-b4892cd266dfafb9c6986ee46a8025c8031c3792.zip | |
Add a new SBThread::SafeToCallFunctions API; this calls over to
the SystemRuntime to check if a thread will have any problems
performing an inferior function call so the driver can skip
making that function call on that thread. Often the function
call can be executed on another thread instead.
<rdar://problem/16777874>
llvm-svn: 208732
Diffstat (limited to 'lldb/source/Plugins/SystemRuntime')
6 files changed, 50 insertions, 0 deletions
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp index 7d62548dbc5..64b2e229962 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp @@ -269,6 +269,14 @@ AppleGetItemInfoHandler::GetItemInfo (Thread &thread, uint64_t item, addr_t page error.Clear(); + if (thread.SafeToCallFunctions() == false) + { + if (log) + log->Printf ("Not safe to call functions on thread 0x%" PRIx64, thread.GetID()); + error.SetErrorString ("Not safe to call functions on this thread."); + return return_value; + } + // Set up the arguments for a call to // struct get_item_info_return_values diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp index ac39fef798b..51b797aa1ac 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp @@ -274,6 +274,14 @@ AppleGetPendingItemsHandler::GetPendingItems (Thread &thread, addr_t queue, addr error.Clear(); + if (thread.SafeToCallFunctions() == false) + { + if (log) + log->Printf ("Not safe to call functions on thread 0x%" PRIx64, thread.GetID()); + error.SetErrorString ("Not safe to call functions on this thread."); + return return_value; + } + // Set up the arguments for a call to // struct get_pending_items_return_values diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp index 403ebf1571f..cd15d475150 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp @@ -282,6 +282,14 @@ AppleGetQueuesHandler::GetCurrentQueues (Thread &thread, addr_t page_to_free, ui error.Clear(); + if (thread.SafeToCallFunctions() == false) + { + if (log) + log->Printf ("Not safe to call functions on thread 0x%" PRIx64, thread.GetID()); + error.SetErrorString ("Not safe to call functions on this thread."); + return return_value; + } + // Set up the arguments for a call to // struct get_current_queues_return_values diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp index 40b61fe9981..46e76663c47 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp @@ -273,6 +273,14 @@ AppleGetThreadItemInfoHandler::GetThreadItemInfo (Thread &thread, tid_t thread_i error.Clear(); + if (thread.SafeToCallFunctions() == false) + { + if (log) + log->Printf ("Not safe to call functions on thread 0x%" PRIx64, thread.GetID()); + error.SetErrorString ("Not safe to call functions on this thread."); + return return_value; + } + // Set up the arguments for a call to // struct get_thread_item_info_return_values diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp index 7ff14fc5e09..f3f1fa31cd7 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -214,6 +214,21 @@ SystemRuntimeMacOSX::GetQueueKind (addr_t dispatch_queue_addr) return kind; } +bool +SystemRuntimeMacOSX::SafeToCallFunctionsOnThisThread (ThreadSP thread_sp) +{ + if (thread_sp && thread_sp->GetStackFrameCount() > 0 && thread_sp->GetFrameWithConcreteFrameIndex(0)) + { + const SymbolContext sym_ctx (thread_sp->GetFrameWithConcreteFrameIndex(0)->GetSymbolContext (eSymbolContextSymbol)); + static ConstString g_select_symbol ("__select"); + if (sym_ctx.GetFunctionName() == g_select_symbol) + { + return false; + } + } + return true; +} + lldb::queue_id_t SystemRuntimeMacOSX::GetQueueIDFromThreadQAddress (lldb::addr_t dispatch_qaddr) { diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h index f7a4d2bfb16..30956fa3ece 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h @@ -108,6 +108,9 @@ public: virtual lldb::QueueKind GetQueueKind (lldb::addr_t dispatch_queue_addr); + virtual bool + SafeToCallFunctionsOnThisThread (lldb::ThreadSP thread_sp); + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ |

