diff options
Diffstat (limited to 'lldb/source/Plugins/SystemRuntime')
4 files changed, 106 insertions, 76 deletions
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp index 2ca367c0cce..19f89f077cd 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp +++ b/lldb/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" @@ -132,11 +133,11 @@ 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; @@ -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; } @@ -207,20 +210,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; } @@ -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/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp index 97699878f5e..cda7264d17b 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp +++ b/lldb/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" @@ -136,14 +137,14 @@ 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)); + 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_pending_items_caller = nullptr; - + // Scope for mutex locker: { Mutex::Locker locker(m_get_pending_items_function_mutex); @@ -165,11 +166,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; } @@ -196,11 +200,10 @@ AppleGetPendingItemsHandler::SetupGetPendingItemsFunction (Thread &thread, Value return args_addr; } } - } - - errors.Clear(); - + + diagnostics.Clear(); + if (get_pending_items_caller == nullptr) { if (log) @@ -212,13 +215,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; } @@ -322,12 +329,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 +349,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/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp index 3370b3257a2..e005d500e0c 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp +++ b/lldb/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" @@ -146,12 +147,12 @@ AppleGetQueuesHandler::Detach () lldb::addr_t AppleGetQueuesHandler::SetupGetQueuesFunction (Thread &thread, ValueList &get_queues_arglist) { - ExecutionContext exe_ctx (thread.shared_from_this()); + ExecutionContext exe_ctx(thread.shared_from_this()); 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: @@ -175,11 +176,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,12 +191,14 @@ 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(); @@ -207,20 +213,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; } @@ -332,10 +341,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 +353,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/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp index ba03f51152c..a528dafb97a 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp +++ b/lldb/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; @@ -141,10 +142,10 @@ AppleGetThreadItemInfoHandler::Detach () lldb::addr_t AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, ValueList &get_thread_item_info_arglist) { - ExecutionContext exe_ctx (thread.shared_from_this()); + ExecutionContext exe_ctx(thread.shared_from_this()); 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; @@ -171,11 +172,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 +189,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(); @@ -210,20 +214,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; } @@ -324,13 +332,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 +362,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) |