diff options
author | Sean Callanan <scallanan@apple.com> | 2016-03-19 00:03:59 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2016-03-19 00:03:59 +0000 |
commit | 579e70c9b0a0826daae6f4fbf704ad54b8e068a6 (patch) | |
tree | 6acdc76a7a2fb7514f71b7be9a545ff7ed252363 /lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp | |
parent | 29365da0e8ac0dd64c90d427ddc349c392fa8c62 (diff) | |
download | bcm5719-llvm-579e70c9b0a0826daae6f4fbf704ad54b8e068a6.tar.gz bcm5719-llvm-579e70c9b0a0826daae6f4fbf704ad54b8e068a6.zip |
Add a DiagnosticManager replace error streams in the expression parser.
We want to do a better job presenting errors that occur when evaluating
expressions. Key to this effort is getting away from a model where all
errors are spat out onto a stream where the client has to take or leave
all of them.
To this end, this patch adds a new class, DiagnosticManager, which
contains errors produced by the compiler or by LLDB as an expression
is created. The DiagnosticManager can dump itself to a log as well as
to a string. Clients will (in the future) be able to filter out the
errors they're interested in by ID or present subsets of these errors
to the user.
This patch is not intended to change the *users* of errors - only to
thread DiagnosticManagers to all the places where streams are used. I
also attempt to standardize our use of errors a bit, removing trailing
newlines and making clients omit 'error:', 'warning:' etc. and instead
pass the Severity flag.
The patch is testsuite-neutral, with modifications to one part of the
MI tests because it relied on "error: error:" being erroneously
printed. This patch fixes the MI variable handling and the testcase.
<rdar://problem/22864976>
llvm-svn: 263859
Diffstat (limited to 'lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp')
-rw-r--r-- | lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp | 45 |
1 files changed, 26 insertions, 19 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) |