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/Target/Process.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/Target/Process.cpp')
-rw-r--r-- | lldb/source/Target/Process.cpp | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 4b03176bdc9..4f15d5880a6 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -14,19 +14,20 @@ // Other libraries and framework includes // Project includes -#include "lldb/Target/Process.h" -#include "lldb/Breakpoint/StoppointCallbackContext.h" +#include "Plugins/Process/Utility/InferiorCallPOSIX.h" #include "lldb/Breakpoint/BreakpointLocation.h" -#include "lldb/Core/Event.h" +#include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Debugger.h" +#include "lldb/Core/Event.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Expression/UserExpression.h" +#include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/IRDynamicChecks.h" +#include "lldb/Expression/UserExpression.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" @@ -39,17 +40,18 @@ #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/ABI.h" +#include "lldb/Target/CPPLanguageRuntime.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/InstrumentationRuntime.h" #include "lldb/Target/JITLoader.h" #include "lldb/Target/JITLoaderList.h" +#include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/MemoryHistory.h" #include "lldb/Target/MemoryRegionInfo.h" -#include "lldb/Target/OperatingSystem.h" -#include "lldb/Target/LanguageRuntime.h" -#include "lldb/Target/CPPLanguageRuntime.h" #include "lldb/Target/ObjCLanguageRuntime.h" +#include "lldb/Target/OperatingSystem.h" #include "lldb/Target/Platform.h" +#include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/SystemRuntime.h" @@ -60,7 +62,6 @@ #include "lldb/Target/ThreadPlanBase.h" #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/NameMatches.h" -#include "Plugins/Process/Utility/InferiorCallPOSIX.h" using namespace lldb; using namespace lldb_private; @@ -5194,35 +5195,33 @@ namespace } // anonymous namespace ExpressionResults -Process::RunThreadPlan (ExecutionContext &exe_ctx, - lldb::ThreadPlanSP &thread_plan_sp, - const EvaluateExpressionOptions &options, - Stream &errors) +Process::RunThreadPlan(ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_plan_sp, + const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager) { ExpressionResults return_value = eExpressionSetupError; if (!thread_plan_sp) { - errors.Printf("RunThreadPlan called with empty thread plan."); + diagnostic_manager.PutCString(eDiagnosticSeverityError, "RunThreadPlan called with empty thread plan."); return eExpressionSetupError; } if (!thread_plan_sp->ValidatePlan(nullptr)) { - errors.Printf ("RunThreadPlan called with an invalid thread plan."); + diagnostic_manager.PutCString(eDiagnosticSeverityError, "RunThreadPlan called with an invalid thread plan."); return eExpressionSetupError; } if (exe_ctx.GetProcessPtr() != this) { - errors.Printf("RunThreadPlan called on wrong process."); + diagnostic_manager.PutCString(eDiagnosticSeverityError, "RunThreadPlan called on wrong process."); return eExpressionSetupError; } Thread *thread = exe_ctx.GetThreadPtr(); if (thread == nullptr) { - errors.Printf("RunThreadPlan called with invalid thread."); + diagnostic_manager.PutCString(eDiagnosticSeverityError, "RunThreadPlan called with invalid thread."); return eExpressionSetupError; } @@ -5245,7 +5244,8 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, if (m_private_state.GetValue() != eStateStopped) { - errors.Printf ("RunThreadPlan called while the private state was not stopped."); + diagnostic_manager.PutCString(eDiagnosticSeverityError, + "RunThreadPlan called while the private state was not stopped."); return eExpressionSetupError; } @@ -5258,7 +5258,8 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, selected_frame_sp = thread->GetSelectedFrame(); if (!selected_frame_sp) { - errors.Printf("RunThreadPlan called without a selected frame on thread %d", thread_idx_id); + diagnostic_manager.Printf(eDiagnosticSeverityError, + "RunThreadPlan called without a selected frame on thread %d", thread_idx_id); return eExpressionSetupError; } } @@ -5400,7 +5401,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, { if (timeout_usec < option_one_thread_timeout) { - errors.Printf("RunThreadPlan called without one thread timeout greater than total timeout"); + diagnostic_manager.PutCString( + eDiagnosticSeverityError, + "RunThreadPlan called without one thread timeout greater than total timeout"); return eExpressionSetupError; } computed_one_thread_timeout = option_one_thread_timeout; @@ -5431,7 +5434,8 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, Event *other_events = listener_sp->PeekAtNextEvent(); if (other_events != nullptr) { - errors.Printf("Calling RunThreadPlan with pending events on the queue."); + diagnostic_manager.PutCString(eDiagnosticSeverityError, + "RunThreadPlan called with pending events on the queue."); return eExpressionSetupError; } @@ -5473,12 +5477,12 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, if (do_resume) { num_resumes++; - Error resume_error = PrivateResume (); + Error resume_error = PrivateResume(); if (!resume_error.Success()) { - errors.Printf("Error resuming inferior the %d time: \"%s\".\n", - num_resumes, - resume_error.AsCString()); + diagnostic_manager.Printf(eDiagnosticSeverityError, + "couldn't resume inferior the %d time: \"%s\".", num_resumes, + resume_error.AsCString()); return_value = eExpressionSetupError; break; } @@ -5491,10 +5495,11 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, if (!got_event) { if (log) - log->Printf ("Process::RunThreadPlan(): didn't get any event after resume %d, exiting.", - num_resumes); + log->Printf("Process::RunThreadPlan(): didn't get any event after resume %" PRIu32 ", exiting.", + num_resumes); - errors.Printf("Didn't get any event after resume %d, exiting.", num_resumes); + diagnostic_manager.Printf(eDiagnosticSeverityError, + "didn't get any event after resume %" PRIu32 ", exiting.", num_resumes); return_value = eExpressionSetupError; break; } @@ -5527,8 +5532,9 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, Halt(clear_thread_plans, use_run_lock); } - errors.Printf("Didn't get running event after initial resume, got %s instead.", - StateAsCString(stop_state)); + diagnostic_manager.Printf(eDiagnosticSeverityError, + "didn't get running event after initial resume, got %s instead.", + StateAsCString(stop_state)); return_value = eExpressionSetupError; break; } @@ -5622,9 +5628,10 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, const bool use_run_lock = false; Halt(clear_thread_plans, use_run_lock); return_value = eExpressionInterrupted; - errors.Printf ("Execution halted by user interrupt."); + diagnostic_manager.PutCString(eDiagnosticSeverityRemark, "execution halted by user interrupt."); if (log) - log->Printf ("Process::RunThreadPlan(): Got interrupted by eBroadcastBitInterrupted, exiting."); + log->Printf( + "Process::RunThreadPlan(): Got interrupted by eBroadcastBitInterrupted, exiting."); break; } else @@ -5727,7 +5734,8 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, if (stop_state == eStateExited) event_to_broadcast_sp = event_sp; - errors.Printf ("Execution stopped with unexpected state.\n"); + diagnostic_manager.PutCString(eDiagnosticSeverityError, + "execution stopped with unexpected state."); return_value = eExpressionInterrupted; break; } |