summaryrefslogtreecommitdiff
path: root/source/Plugins/SystemRuntime
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
commitf3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch)
tree48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /source/Plugins/SystemRuntime
parent2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff)
downloadsrc-test2-f3fbd1c0586ff6ec7895991e6c28f61a503c36a8.tar.gz
src-test2-f3fbd1c0586ff6ec7895991e6c28f61a503c36a8.zip
Notes
Diffstat (limited to 'source/Plugins/SystemRuntime')
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp73
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h8
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp77
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h8
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp75
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h8
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp75
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h8
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/Makefile14
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp50
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h6
11 files changed, 211 insertions, 191 deletions
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
index 2ca367c0cce8..38998469dcbe 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
+#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Symbol/ClangASTContext.h"
@@ -95,12 +96,12 @@ extern \"C\"
} \n\
";
-AppleGetItemInfoHandler::AppleGetItemInfoHandler (Process *process) :
- m_process (process),
- m_get_item_info_impl_code (),
- m_get_item_info_function_mutex(),
- m_get_item_info_return_buffer_addr (LLDB_INVALID_ADDRESS),
- m_get_item_info_retbuffer_mutex()
+AppleGetItemInfoHandler::AppleGetItemInfoHandler(Process *process)
+ : m_process(process),
+ m_get_item_info_impl_code(),
+ m_get_item_info_function_mutex(),
+ m_get_item_info_return_buffer_addr(LLDB_INVALID_ADDRESS),
+ m_get_item_info_retbuffer_mutex()
{
}
@@ -109,14 +110,14 @@ AppleGetItemInfoHandler::~AppleGetItemInfoHandler ()
}
void
-AppleGetItemInfoHandler::Detach ()
+AppleGetItemInfoHandler::Detach()
{
if (m_process && m_process->IsAlive() && m_get_item_info_return_buffer_addr != LLDB_INVALID_ADDRESS)
{
- Mutex::Locker locker;
- locker.TryLock (m_get_item_info_retbuffer_mutex); // Even if we don't get the lock, deallocate the buffer
- m_process->DeallocateMemory (m_get_item_info_return_buffer_addr);
+ std::unique_lock<std::mutex> lock(m_get_item_info_retbuffer_mutex, std::defer_lock);
+ lock.try_lock(); // Even if we don't get the lock, deallocate the buffer
+ m_process->DeallocateMemory(m_get_item_info_return_buffer_addr);
}
}
@@ -132,18 +133,18 @@ AppleGetItemInfoHandler::Detach ()
// make the function call.
lldb::addr_t
-AppleGetItemInfoHandler::SetupGetItemInfoFunction (Thread &thread, ValueList &get_item_info_arglist)
+AppleGetItemInfoHandler::SetupGetItemInfoFunction(Thread &thread, ValueList &get_item_info_arglist)
{
- ExecutionContext exe_ctx (thread.shared_from_this());
- StreamString errors;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME));
+ ExecutionContext exe_ctx(thread.shared_from_this());
+ DiagnosticManager diagnostics;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME));
lldb::addr_t args_addr = LLDB_INVALID_ADDRESS;
FunctionCaller *get_item_info_caller = nullptr;
// Scope for mutex locker:
{
- Mutex::Locker locker(m_get_item_info_function_mutex);
-
+ std::lock_guard<std::mutex> guard(m_get_item_info_function_mutex);
+
// First stage is to make the UtilityFunction to hold our injected function:
if (!m_get_item_info_impl_code.get())
@@ -161,11 +162,14 @@ AppleGetItemInfoHandler::SetupGetItemInfoFunction (Thread &thread, ValueList &ge
log->Printf ("Failed to get utility function: %s.", error.AsCString());
return args_addr;
}
-
- if (!m_get_item_info_impl_code->Install(errors, exe_ctx))
+
+ if (!m_get_item_info_impl_code->Install(diagnostics, exe_ctx))
{
if (log)
- log->Printf ("Failed to install get-item-info introspection: %s.", errors.GetData());
+ {
+ log->Printf("Failed to install get-item-info introspection.");
+ diagnostics.Dump(log);
+ }
m_get_item_info_impl_code.reset();
return args_addr;
}
@@ -174,7 +178,6 @@ AppleGetItemInfoHandler::SetupGetItemInfoFunction (Thread &thread, ValueList &ge
{
if (log)
log->Printf("No get-item-info introspection code found.");
- errors.Printf ("No get-item-info introspection code found.");
return LLDB_INVALID_ADDRESS;
}
@@ -186,6 +189,7 @@ AppleGetItemInfoHandler::SetupGetItemInfoFunction (Thread &thread, ValueList &ge
get_item_info_caller = m_get_item_info_impl_code->MakeFunctionCaller(get_item_info_return_type,
get_item_info_arglist,
+ thread.shared_from_this(),
error);
if (error.Fail())
{
@@ -207,20 +211,24 @@ AppleGetItemInfoHandler::SetupGetItemInfoFunction (Thread &thread, ValueList &ge
}
}
}
-
- errors.Clear();
-
+
+ diagnostics.Clear();
+
// Now write down the argument values for this particular call. This looks like it might be a race condition
// if other threads were calling into here, but actually it isn't because we allocate a new args structure for
// this call by passing args_addr = LLDB_INVALID_ADDRESS...
- if (!get_item_info_caller->WriteFunctionArguments (exe_ctx, args_addr, get_item_info_arglist, errors))
+ if (!get_item_info_caller->WriteFunctionArguments(exe_ctx, args_addr, get_item_info_arglist, diagnostics))
{
if (log)
- log->Printf ("Error writing get-item-info function arguments: \"%s\".", errors.GetData());
+ {
+ log->Printf("Error writing get-item-info function arguments.");
+ diagnostics.Dump(log);
+ }
+
return args_addr;
}
-
+
return args_addr;
}
@@ -288,8 +296,7 @@ AppleGetItemInfoHandler::GetItemInfo (Thread &thread, uint64_t item, addr_t page
page_to_free_size_value.SetValueType (Value::eValueTypeScalar);
page_to_free_size_value.SetCompilerType (clang_uint64_type);
-
- Mutex::Locker locker(m_get_item_info_retbuffer_mutex);
+ std::lock_guard<std::mutex> guard(m_get_item_info_retbuffer_mutex);
if (m_get_item_info_return_buffer_addr == LLDB_INVALID_ADDRESS)
{
addr_t bufaddr = process_sp->AllocateMemory (32, ePermissionsReadable | ePermissionsWritable, error);
@@ -322,12 +329,12 @@ AppleGetItemInfoHandler::GetItemInfo (Thread &thread, uint64_t item, addr_t page
page_to_free_size_value.GetScalar() = page_to_free_size;
argument_values.PushValue (page_to_free_size_value);
- addr_t args_addr = SetupGetItemInfoFunction (thread, argument_values);
+ addr_t args_addr = SetupGetItemInfoFunction(thread, argument_values);
- StreamString errors;
+ DiagnosticManager diagnostics;
ExecutionContext exe_ctx;
EvaluateExpressionOptions options;
- options.SetUnwindOnError (true);
+ options.SetUnwindOnError(true);
options.SetIgnoreBreakpoints (true);
options.SetStopOthers (true);
options.SetTimeoutUsec(500000);
@@ -351,8 +358,8 @@ AppleGetItemInfoHandler::GetItemInfo (Thread &thread, uint64_t item, addr_t page
error.SetErrorString("Could not retrieve function caller for __introspection_dispatch_queue_item_get_info.");
return return_value;
}
-
- func_call_ret = func_caller->ExecuteFunction (exe_ctx, &args_addr, options, errors, results);
+
+ func_call_ret = func_caller->ExecuteFunction(exe_ctx, &args_addr, options, diagnostics, results);
if (func_call_ret != eExpressionCompleted || !error.Success())
{
if (log)
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h
index 51182a624939..dc341d672d6a 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h
@@ -13,13 +13,14 @@
// C Includes
// C++ Includes
#include <map>
+#include <mutex>
#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/Core/Error.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/CompilerType.h"
// This class will insert a UtilityFunction into the inferior process for
@@ -105,11 +106,10 @@ private:
lldb_private::Process *m_process;
std::unique_ptr<UtilityFunction> m_get_item_info_impl_code;
- Mutex m_get_item_info_function_mutex;
+ std::mutex m_get_item_info_function_mutex;
lldb::addr_t m_get_item_info_return_buffer_addr;
- Mutex m_get_item_info_retbuffer_mutex;
-
+ std::mutex m_get_item_info_retbuffer_mutex;
};
} // using namespace lldb_private
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
index 97699878f5ee..d311f5fb5f6e 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
+#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Symbol/ClangASTContext.h"
@@ -99,12 +100,12 @@ extern \"C\"
} \n\
";
-AppleGetPendingItemsHandler::AppleGetPendingItemsHandler (Process *process) :
- m_process (process),
- m_get_pending_items_impl_code (),
- m_get_pending_items_function_mutex(),
- m_get_pending_items_return_buffer_addr (LLDB_INVALID_ADDRESS),
- m_get_pending_items_retbuffer_mutex()
+AppleGetPendingItemsHandler::AppleGetPendingItemsHandler(Process *process)
+ : m_process(process),
+ m_get_pending_items_impl_code(),
+ m_get_pending_items_function_mutex(),
+ m_get_pending_items_return_buffer_addr(LLDB_INVALID_ADDRESS),
+ m_get_pending_items_retbuffer_mutex()
{
}
@@ -113,14 +114,13 @@ AppleGetPendingItemsHandler::~AppleGetPendingItemsHandler ()
}
void
-AppleGetPendingItemsHandler::Detach ()
+AppleGetPendingItemsHandler::Detach()
{
-
if (m_process && m_process->IsAlive() && m_get_pending_items_return_buffer_addr != LLDB_INVALID_ADDRESS)
{
- Mutex::Locker locker;
- locker.TryLock (m_get_pending_items_retbuffer_mutex); // Even if we don't get the lock, deallocate the buffer
- m_process->DeallocateMemory (m_get_pending_items_return_buffer_addr);
+ std::unique_lock<std::mutex> lock(m_get_pending_items_retbuffer_mutex, std::defer_lock);
+ lock.try_lock(); // Even if we don't get the lock, deallocate the buffer
+ m_process->DeallocateMemory(m_get_pending_items_return_buffer_addr);
}
}
@@ -136,18 +136,20 @@ AppleGetPendingItemsHandler::Detach ()
// make the function call.
lldb::addr_t
-AppleGetPendingItemsHandler::SetupGetPendingItemsFunction (Thread &thread, ValueList &get_pending_items_arglist)
+AppleGetPendingItemsHandler::SetupGetPendingItemsFunction(Thread &thread, ValueList &get_pending_items_arglist)
{
- ExecutionContext exe_ctx (thread.shared_from_this());
- StreamString errors;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME));
+ ThreadSP thread_sp (thread.shared_from_this());
+ ExecutionContext exe_ctx (thread_sp);
+ DiagnosticManager diagnostics;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME));
+
lldb::addr_t args_addr = LLDB_INVALID_ADDRESS;
FunctionCaller *get_pending_items_caller = nullptr;
-
+
// Scope for mutex locker:
{
- Mutex::Locker locker(m_get_pending_items_function_mutex);
-
+ std::lock_guard<std::mutex> guard(m_get_pending_items_function_mutex);
+
// First stage is to make the ClangUtility to hold our injected function:
if (!m_get_pending_items_impl_code.get())
@@ -165,11 +167,14 @@ AppleGetPendingItemsHandler::SetupGetPendingItemsFunction (Thread &thread, Value
log->Printf ("Failed to get UtilityFunction for pending-items introspection: %s.", error.AsCString());
return args_addr;
}
-
- if (!m_get_pending_items_impl_code->Install(errors, exe_ctx))
+
+ if (!m_get_pending_items_impl_code->Install(diagnostics, exe_ctx))
{
if (log)
- log->Printf ("Failed to install pending-items introspection: %s.", errors.GetData());
+ {
+ log->Printf("Failed to install pending-items introspection.");
+ diagnostics.Dump(log);
+ }
m_get_pending_items_impl_code.reset();
return args_addr;
}
@@ -187,6 +192,7 @@ AppleGetPendingItemsHandler::SetupGetPendingItemsFunction (Thread &thread, Value
CompilerType get_pending_items_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
get_pending_items_caller = m_get_pending_items_impl_code->MakeFunctionCaller (get_pending_items_return_type,
get_pending_items_arglist,
+ thread_sp,
error);
if (error.Fail())
{
@@ -196,11 +202,10 @@ AppleGetPendingItemsHandler::SetupGetPendingItemsFunction (Thread &thread, Value
return args_addr;
}
}
-
}
-
- errors.Clear();
-
+
+ diagnostics.Clear();
+
if (get_pending_items_caller == nullptr)
{
if (log)
@@ -212,13 +217,17 @@ AppleGetPendingItemsHandler::SetupGetPendingItemsFunction (Thread &thread, Value
// if other threads were calling into here, but actually it isn't because we allocate a new args structure for
// this call by passing args_addr = LLDB_INVALID_ADDRESS...
- if (!get_pending_items_caller->WriteFunctionArguments (exe_ctx, args_addr, get_pending_items_arglist, errors))
+ if (!get_pending_items_caller->WriteFunctionArguments(exe_ctx, args_addr, get_pending_items_arglist, diagnostics))
{
if (log)
- log->Printf ("Error writing pending-items function arguments: \"%s\".", errors.GetData());
+ {
+ log->Printf("Error writing pending-items function arguments.");
+ diagnostics.Dump(log);
+ }
+
return args_addr;
}
-
+
return args_addr;
}
@@ -288,8 +297,7 @@ AppleGetPendingItemsHandler::GetPendingItems (Thread &thread, addr_t queue, addr
page_to_free_size_value.SetValueType (Value::eValueTypeScalar);
page_to_free_size_value.SetCompilerType (clang_uint64_type);
-
- Mutex::Locker locker(m_get_pending_items_retbuffer_mutex);
+ std::lock_guard<std::mutex> guard(m_get_pending_items_retbuffer_mutex);
if (m_get_pending_items_return_buffer_addr == LLDB_INVALID_ADDRESS)
{
addr_t bufaddr = process_sp->AllocateMemory (32, ePermissionsReadable | ePermissionsWritable, error);
@@ -322,12 +330,12 @@ AppleGetPendingItemsHandler::GetPendingItems (Thread &thread, addr_t queue, addr
page_to_free_size_value.GetScalar() = page_to_free_size;
argument_values.PushValue (page_to_free_size_value);
- addr_t args_addr = SetupGetPendingItemsFunction (thread, argument_values);
+ addr_t args_addr = SetupGetPendingItemsFunction(thread, argument_values);
- StreamString errors;
+ DiagnosticManager diagnostics;
ExecutionContext exe_ctx;
FunctionCaller *get_pending_items_caller = m_get_pending_items_impl_code->GetFunctionCaller();
-
+
EvaluateExpressionOptions options;
options.SetUnwindOnError (true);
options.SetIgnoreBreakpoints (true);
@@ -342,10 +350,9 @@ AppleGetPendingItemsHandler::GetPendingItems (Thread &thread, addr_t queue, addr
return return_value;
}
-
ExpressionResults func_call_ret;
Value results;
- func_call_ret = get_pending_items_caller->ExecuteFunction (exe_ctx, &args_addr, options, errors, results);
+ func_call_ret = get_pending_items_caller->ExecuteFunction(exe_ctx, &args_addr, options, diagnostics, results);
if (func_call_ret != eExpressionCompleted || !error.Success())
{
if (log)
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h
index 445c4a0fb82b..96fbf4a548c4 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h
@@ -13,12 +13,13 @@
// C Includes
// C++ Includes
#include <map>
+#include <mutex>
#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/Core/Error.h"
-#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/CompilerType.h"
// This class will insert a UtilityFunction into the inferior process for
@@ -107,11 +108,10 @@ private:
lldb_private::Process *m_process;
std::unique_ptr<UtilityFunction> m_get_pending_items_impl_code;
- Mutex m_get_pending_items_function_mutex;
+ std::mutex m_get_pending_items_function_mutex;
lldb::addr_t m_get_pending_items_return_buffer_addr;
- Mutex m_get_pending_items_retbuffer_mutex;
-
+ std::mutex m_get_pending_items_retbuffer_mutex;
};
} // using namespace lldb_private
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
index 3370b3257a25..e90fe6d5d17d 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
@@ -18,6 +18,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
+#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Symbol/ClangASTContext.h"
@@ -95,12 +96,12 @@ extern \"C\"
} \n\
";
-AppleGetQueuesHandler::AppleGetQueuesHandler (Process *process) :
- m_process (process),
- m_get_queues_impl_code_up (),
- m_get_queues_function_mutex(),
- m_get_queues_return_buffer_addr (LLDB_INVALID_ADDRESS),
- m_get_queues_retbuffer_mutex()
+AppleGetQueuesHandler::AppleGetQueuesHandler(Process *process)
+ : m_process(process),
+ m_get_queues_impl_code_up(),
+ m_get_queues_function_mutex(),
+ m_get_queues_return_buffer_addr(LLDB_INVALID_ADDRESS),
+ m_get_queues_retbuffer_mutex()
{
}
@@ -109,14 +110,14 @@ AppleGetQueuesHandler::~AppleGetQueuesHandler ()
}
void
-AppleGetQueuesHandler::Detach ()
+AppleGetQueuesHandler::Detach()
{
if (m_process && m_process->IsAlive() && m_get_queues_return_buffer_addr != LLDB_INVALID_ADDRESS)
{
- Mutex::Locker locker;
- locker.TryLock (m_get_queues_retbuffer_mutex); // Even if we don't get the lock, deallocate the buffer
- m_process->DeallocateMemory (m_get_queues_return_buffer_addr);
+ std::unique_lock<std::mutex> lock(m_get_queues_retbuffer_mutex, std::defer_lock);
+ lock.try_lock(); // Even if we don't get the lock, deallocate the buffer
+ m_process->DeallocateMemory(m_get_queues_return_buffer_addr);
}
}
@@ -146,18 +147,20 @@ AppleGetQueuesHandler::Detach ()
lldb::addr_t
AppleGetQueuesHandler::SetupGetQueuesFunction (Thread &thread, ValueList &get_queues_arglist)
{
- ExecutionContext exe_ctx (thread.shared_from_this());
+ ThreadSP thread_sp(thread.shared_from_this());
+ ExecutionContext exe_ctx (thread_sp);
+
Address impl_code_address;
- StreamString errors;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME));
+ DiagnosticManager diagnostics;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME));
lldb::addr_t args_addr = LLDB_INVALID_ADDRESS;
-
+
FunctionCaller *get_queues_caller = nullptr;
// Scope for mutex locker:
{
- Mutex::Locker locker(m_get_queues_function_mutex);
-
+ std::lock_guard<std::mutex> guard(m_get_queues_function_mutex);
+
// First stage is to make the ClangUtility to hold our injected function:
if (!m_get_queues_impl_code_up.get())
@@ -175,11 +178,14 @@ AppleGetQueuesHandler::SetupGetQueuesFunction (Thread &thread, ValueList &get_qu
log->Printf ("Failed to get UtilityFunction for queues introspection: %s.", error.AsCString());
return args_addr;
}
-
- if (!m_get_queues_impl_code_up->Install(errors, exe_ctx))
+
+ if (!m_get_queues_impl_code_up->Install(diagnostics, exe_ctx))
{
if (log)
- log->Printf ("Failed to install queues introspection: %s.", errors.GetData());
+ {
+ log->Printf("Failed to install queues introspection");
+ diagnostics.Dump(log);
+ }
m_get_queues_impl_code_up.reset();
return args_addr;
}
@@ -187,18 +193,21 @@ AppleGetQueuesHandler::SetupGetQueuesFunction (Thread &thread, ValueList &get_qu
else
{
if (log)
+ {
log->Printf("No queues introspection code found.");
- errors.Printf ("No queues introspection code found.");
+ diagnostics.Dump(log);
+ }
return LLDB_INVALID_ADDRESS;
}
}
-
+
// Next make the runner function for our implementation utility function.
ClangASTContext *clang_ast_context = thread.GetProcess()->GetTarget().GetScratchClangASTContext();
CompilerType get_queues_return_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
Error error;
get_queues_caller = m_get_queues_impl_code_up->MakeFunctionCaller (get_queues_return_type,
get_queues_arglist,
+ thread_sp,
error);
if (error.Fail())
{
@@ -207,20 +216,23 @@ AppleGetQueuesHandler::SetupGetQueuesFunction (Thread &thread, ValueList &get_qu
return args_addr;
}
}
-
- errors.Clear();
-
+
+ diagnostics.Clear();
+
// Now write down the argument values for this particular call. This looks like it might be a race condition
// if other threads were calling into here, but actually it isn't because we allocate a new args structure for
// this call by passing args_addr = LLDB_INVALID_ADDRESS...
- if (!get_queues_caller->WriteFunctionArguments (exe_ctx, args_addr, get_queues_arglist, errors))
+ if (!get_queues_caller->WriteFunctionArguments(exe_ctx, args_addr, get_queues_arglist, diagnostics))
{
if (log)
- log->Printf ("Error writing get-queues function arguments: \"%s\".", errors.GetData());
+ {
+ log->Printf("Error writing get-queues function arguments.");
+ diagnostics.Dump(log);
+ }
return args_addr;
}
-
+
return args_addr;
}
@@ -285,8 +297,7 @@ AppleGetQueuesHandler::GetCurrentQueues (Thread &thread, addr_t page_to_free, ui
page_to_free_size_value.SetValueType (Value::eValueTypeScalar);
page_to_free_size_value.SetCompilerType (clang_uint64_type);
-
- Mutex::Locker locker(m_get_queues_retbuffer_mutex);
+ std::lock_guard<std::mutex> guard(m_get_queues_retbuffer_mutex);
if (m_get_queues_return_buffer_addr == LLDB_INVALID_ADDRESS)
{
addr_t bufaddr = process_sp->AllocateMemory (32, ePermissionsReadable | ePermissionsWritable, error);
@@ -332,10 +343,10 @@ AppleGetQueuesHandler::GetCurrentQueues (Thread &thread, addr_t page_to_free, ui
return return_value;
}
- StreamString errors;
+ DiagnosticManager diagnostics;
ExecutionContext exe_ctx;
EvaluateExpressionOptions options;
- options.SetUnwindOnError (true);
+ options.SetUnwindOnError(true);
options.SetIgnoreBreakpoints (true);
options.SetStopOthers (true);
options.SetTimeoutUsec(500000);
@@ -344,7 +355,7 @@ AppleGetQueuesHandler::GetCurrentQueues (Thread &thread, addr_t page_to_free, ui
ExpressionResults func_call_ret;
Value results;
- func_call_ret = get_queues_caller->ExecuteFunction (exe_ctx, &args_addr, options, errors, results);
+ func_call_ret = get_queues_caller->ExecuteFunction(exe_ctx, &args_addr, options, diagnostics, results);
if (func_call_ret != eExpressionCompleted || !error.Success())
{
if (log)
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h
index 6f3df5f62807..b7ca26dafc30 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h
@@ -13,12 +13,13 @@
// C Includes
// C++ Includes
#include <map>
+#include <mutex>
#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/Core/Error.h"
-#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/CompilerType.h"
// This class will insert a UtilityFunction into the inferior process for
@@ -104,11 +105,10 @@ private:
lldb_private::Process *m_process;
std::unique_ptr<UtilityFunction> m_get_queues_impl_code_up;
- Mutex m_get_queues_function_mutex;
+ std::mutex m_get_queues_function_mutex;
lldb::addr_t m_get_queues_return_buffer_addr;
- Mutex m_get_queues_retbuffer_mutex;
-
+ std::mutex m_get_queues_retbuffer_mutex;
};
} // using namespace lldb_private
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
index ba03f51152c0..85ad012c59fc 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
@@ -14,12 +14,12 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
+#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/Expression.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
@@ -30,6 +30,7 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/lldb-private.h"
using namespace lldb;
using namespace lldb_private;
@@ -102,12 +103,12 @@ extern \"C\"
} \n\
";
-AppleGetThreadItemInfoHandler::AppleGetThreadItemInfoHandler (Process *process) :
- m_process (process),
- m_get_thread_item_info_impl_code (),
- m_get_thread_item_info_function_mutex(),
- m_get_thread_item_info_return_buffer_addr (LLDB_INVALID_ADDRESS),
- m_get_thread_item_info_retbuffer_mutex()
+AppleGetThreadItemInfoHandler::AppleGetThreadItemInfoHandler(Process *process)
+ : m_process(process),
+ m_get_thread_item_info_impl_code(),
+ m_get_thread_item_info_function_mutex(),
+ m_get_thread_item_info_return_buffer_addr(LLDB_INVALID_ADDRESS),
+ m_get_thread_item_info_retbuffer_mutex()
{
}
@@ -116,14 +117,14 @@ AppleGetThreadItemInfoHandler::~AppleGetThreadItemInfoHandler ()
}
void
-AppleGetThreadItemInfoHandler::Detach ()
+AppleGetThreadItemInfoHandler::Detach()
{
if (m_process && m_process->IsAlive() && m_get_thread_item_info_return_buffer_addr != LLDB_INVALID_ADDRESS)
{
- Mutex::Locker locker;
- locker.TryLock (m_get_thread_item_info_retbuffer_mutex); // Even if we don't get the lock, deallocate the buffer
- m_process->DeallocateMemory (m_get_thread_item_info_return_buffer_addr);
+ std::unique_lock<std::mutex> lock(m_get_thread_item_info_retbuffer_mutex, std::defer_lock);
+ lock.try_lock(); // Even if we don't get the lock, deallocate the buffer
+ m_process->DeallocateMemory(m_get_thread_item_info_return_buffer_addr);
}
}
@@ -141,17 +142,18 @@ AppleGetThreadItemInfoHandler::Detach ()
lldb::addr_t
AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, ValueList &get_thread_item_info_arglist)
{
- ExecutionContext exe_ctx (thread.shared_from_this());
+ ThreadSP thread_sp(thread.shared_from_this());
+ ExecutionContext exe_ctx (thread_sp);
Address impl_code_address;
- StreamString errors;
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME));
+ DiagnosticManager diagnostics;
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYSTEM_RUNTIME));
lldb::addr_t args_addr = LLDB_INVALID_ADDRESS;
FunctionCaller *get_thread_item_info_caller = nullptr;
// Scope for mutex locker:
{
- Mutex::Locker locker(m_get_thread_item_info_function_mutex);
-
+ std::lock_guard<std::mutex> guard(m_get_thread_item_info_function_mutex);
+
// First stage is to make the ClangUtility to hold our injected function:
if (!m_get_thread_item_info_impl_code.get())
@@ -171,11 +173,15 @@ AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, V
m_get_thread_item_info_impl_code.reset();
return args_addr;
}
-
- if (!m_get_thread_item_info_impl_code->Install(errors, exe_ctx))
+
+ if (!m_get_thread_item_info_impl_code->Install(diagnostics, exe_ctx))
{
if (log)
- log->Printf ("Failed to install get-thread-item-info introspection: %s.", errors.GetData());
+ {
+ log->Printf("Failed to install get-thread-item-info introspection.");
+ diagnostics.Dump(log);
+ }
+
m_get_thread_item_info_impl_code.reset();
return args_addr;
}
@@ -184,10 +190,9 @@ AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, V
{
if (log)
log->Printf("No get-thread-item-info introspection code found.");
- errors.Printf ("No get-thread-item-info introspection code found.");
return LLDB_INVALID_ADDRESS;
}
-
+
// Also make the FunctionCaller for this UtilityFunction:
ClangASTContext *clang_ast_context = thread.GetProcess()->GetTarget().GetScratchClangASTContext();
@@ -195,6 +200,7 @@ AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, V
get_thread_item_info_caller = m_get_thread_item_info_impl_code->MakeFunctionCaller (get_thread_item_info_return_type,
get_thread_item_info_arglist,
+ thread_sp,
error);
if (error.Fail())
{
@@ -210,20 +216,24 @@ AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, V
get_thread_item_info_caller = m_get_thread_item_info_impl_code->GetFunctionCaller();
}
}
-
- errors.Clear();
-
+
+ diagnostics.Clear();
+
// Now write down the argument values for this particular call. This looks like it might be a race condition
// if other threads were calling into here, but actually it isn't because we allocate a new args structure for
// this call by passing args_addr = LLDB_INVALID_ADDRESS...
- if (!get_thread_item_info_caller->WriteFunctionArguments (exe_ctx, args_addr, get_thread_item_info_arglist, errors))
+ if (!get_thread_item_info_caller->WriteFunctionArguments(exe_ctx, args_addr, get_thread_item_info_arglist,
+ diagnostics))
{
if (log)
- log->Printf ("Error writing get-thread-item-info function arguments: \"%s\".", errors.GetData());
+ {
+ log->Printf("Error writing get-thread-item-info function arguments");
+ diagnostics.Dump(log);
+ }
return args_addr;
}
-
+
return args_addr;
}
@@ -290,8 +300,7 @@ AppleGetThreadItemInfoHandler::GetThreadItemInfo (Thread &thread, tid_t thread_i
page_to_free_size_value.SetValueType (Value::eValueTypeScalar);
page_to_free_size_value.SetCompilerType (clang_uint64_type);
-
- Mutex::Locker locker(m_get_thread_item_info_retbuffer_mutex);
+ std::lock_guard<std::mutex> guard(m_get_thread_item_info_retbuffer_mutex);
if (m_get_thread_item_info_return_buffer_addr == LLDB_INVALID_ADDRESS)
{
addr_t bufaddr = process_sp->AllocateMemory (32, ePermissionsReadable | ePermissionsWritable, error);
@@ -324,13 +333,13 @@ AppleGetThreadItemInfoHandler::GetThreadItemInfo (Thread &thread, tid_t thread_i
page_to_free_size_value.GetScalar() = page_to_free_size;
argument_values.PushValue (page_to_free_size_value);
- addr_t args_addr = SetupGetThreadItemInfoFunction (thread, argument_values);
+ addr_t args_addr = SetupGetThreadItemInfoFunction(thread, argument_values);
- StreamString errors;
+ DiagnosticManager diagnostics;
ExecutionContext exe_ctx;
EvaluateExpressionOptions options;
FunctionCaller *get_thread_item_info_caller = nullptr;
-
+
options.SetUnwindOnError (true);
options.SetIgnoreBreakpoints (true);
options.SetStopOthers (true);
@@ -354,7 +363,7 @@ AppleGetThreadItemInfoHandler::GetThreadItemInfo (Thread &thread, tid_t thread_i
ExpressionResults func_call_ret;
Value results;
- func_call_ret = get_thread_item_info_caller->ExecuteFunction (exe_ctx, &args_addr, options, errors, results);
+ func_call_ret = get_thread_item_info_caller->ExecuteFunction(exe_ctx, &args_addr, options, diagnostics, results);
if (func_call_ret != eExpressionCompleted || !error.Success())
{
if (log)
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h
index c1798fb515b4..21a63e8c225a 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h
@@ -13,12 +13,13 @@
// C Includes
// C++ Includes
#include <map>
+#include <mutex>
#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/Core/Error.h"
-#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/CompilerType.h"
// This class will insert a UtilityFunction into the inferior process for
@@ -101,11 +102,10 @@ private:
lldb_private::Process *m_process;
std::unique_ptr<UtilityFunction> m_get_thread_item_info_impl_code;
- Mutex m_get_thread_item_info_function_mutex;
+ std::mutex m_get_thread_item_info_function_mutex;
lldb::addr_t m_get_thread_item_info_return_buffer_addr;
- Mutex m_get_thread_item_info_retbuffer_mutex;
-
+ std::mutex m_get_thread_item_info_retbuffer_mutex;
};
} // using namespace lldb_private
diff --git a/source/Plugins/SystemRuntime/MacOSX/Makefile b/source/Plugins/SystemRuntime/MacOSX/Makefile
deleted file mode 100644
index eebfb52073d5..000000000000
--- a/source/Plugins/SystemRuntime/MacOSX/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-##===- source/Plugins/SystemRuntime/MacOSX ----*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../../..
-LIBRARYNAME := lldbPluginSystemRuntimeMacOSX
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
index 1097ef36960e..9ec36b383af3 100644
--- a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
+++ b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
@@ -83,25 +83,25 @@ SystemRuntimeMacOSX::CreateInstance (Process* process)
//----------------------------------------------------------------------
// Constructor
//----------------------------------------------------------------------
-SystemRuntimeMacOSX::SystemRuntimeMacOSX (Process* process) :
- SystemRuntime(process),
- m_break_id(LLDB_INVALID_BREAK_ID),
- m_mutex(Mutex::eMutexTypeRecursive),
- m_get_queues_handler(process),
- m_get_pending_items_handler(process),
- m_get_item_info_handler(process),
- m_get_thread_item_info_handler(process),
- m_page_to_free(LLDB_INVALID_ADDRESS),
- m_page_to_free_size(0),
- m_lib_backtrace_recording_info(),
- m_dispatch_queue_offsets_addr (LLDB_INVALID_ADDRESS),
- m_libdispatch_offsets(),
- m_libpthread_layout_offsets_addr (LLDB_INVALID_ADDRESS),
- m_libpthread_offsets(),
- m_dispatch_tsd_indexes_addr (LLDB_INVALID_ADDRESS),
- m_libdispatch_tsd_indexes(),
- m_dispatch_voucher_offsets_addr (LLDB_INVALID_ADDRESS),
- m_libdispatch_voucher_offsets()
+SystemRuntimeMacOSX::SystemRuntimeMacOSX(Process *process)
+ : SystemRuntime(process),
+ m_break_id(LLDB_INVALID_BREAK_ID),
+ m_mutex(),
+ m_get_queues_handler(process),
+ m_get_pending_items_handler(process),
+ m_get_item_info_handler(process),
+ m_get_thread_item_info_handler(process),
+ m_page_to_free(LLDB_INVALID_ADDRESS),
+ m_page_to_free_size(0),
+ m_lib_backtrace_recording_info(),
+ m_dispatch_queue_offsets_addr(LLDB_INVALID_ADDRESS),
+ m_libdispatch_offsets(),
+ m_libpthread_layout_offsets_addr(LLDB_INVALID_ADDRESS),
+ m_libpthread_offsets(),
+ m_dispatch_tsd_indexes_addr(LLDB_INVALID_ADDRESS),
+ m_libdispatch_tsd_indexes(),
+ m_dispatch_voucher_offsets_addr(LLDB_INVALID_ADDRESS),
+ m_libdispatch_voucher_offsets()
{
}
@@ -128,7 +128,7 @@ SystemRuntimeMacOSX::Detach ()
void
SystemRuntimeMacOSX::Clear (bool clear_process)
{
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process->IsAlive() && LLDB_BREAK_ID_IS_VALID(m_break_id))
m_process->ClearBreakpointSiteByID(m_break_id);
@@ -486,7 +486,7 @@ SystemRuntimeMacOSX::GetExtendedBacktraceThread (ThreadSP real_thread, ConstStri
}
else
{
- ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread());
+ ThreadSP cur_thread_sp (m_process->GetThreadList().GetExpressionExecutionThread());
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;
@@ -524,7 +524,7 @@ SystemRuntimeMacOSX::GetExtendedBacktraceFromItemRef (lldb::addr_t item_ref)
ThreadSP return_thread_sp;
AppleGetItemInfoHandler::GetItemInfoReturnInfo ret;
- ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread());
+ ThreadSP cur_thread_sp (m_process->GetThreadList().GetExpressionExecutionThread());
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;
@@ -696,7 +696,7 @@ SystemRuntimeMacOSX::PopulateQueueList (lldb_private::QueueList &queue_list)
if (BacktraceRecordingHeadersInitialized())
{
AppleGetQueuesHandler::GetQueuesReturnInfo queue_info_pointer;
- ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread());
+ ThreadSP cur_thread_sp (m_process->GetThreadList().GetExpressionExecutionThread());
if (cur_thread_sp)
{
Error error;
@@ -760,7 +760,7 @@ SystemRuntimeMacOSX::GetPendingItemRefsForQueue (lldb::addr_t queue)
{
PendingItemsForQueue pending_item_refs;
AppleGetPendingItemsHandler::GetPendingItemsReturnInfo pending_items_pointer;
- ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread());
+ ThreadSP cur_thread_sp (m_process->GetThreadList().GetExpressionExecutionThread());
if (cur_thread_sp)
{
Error error;
@@ -859,7 +859,7 @@ SystemRuntimeMacOSX::CompleteQueueItem (QueueItem *queue_item, addr_t item_ref)
{
AppleGetItemInfoHandler::GetItemInfoReturnInfo ret;
- ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread());
+ ThreadSP cur_thread_sp (m_process->GetThreadList().GetExpressionExecutionThread());
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;
diff --git a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
index 8fe15fa4d8a5..b685a056f5c2 100644
--- a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
+++ b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
@@ -12,8 +12,9 @@
// C Includes
// C++ Includes
-#include <vector>
+#include <mutex>
#include <string>
+#include <vector>
// Other libraries and framework include
// Project includes
@@ -23,7 +24,6 @@
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/UUID.h"
#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/QueueItem.h"
@@ -124,7 +124,7 @@ public:
protected:
lldb::user_id_t m_break_id;
- mutable lldb_private::Mutex m_mutex;
+ mutable std::recursive_mutex m_mutex;
private:
struct libBacktraceRecording_info {