diff options
author | Greg Clayton <gclayton@apple.com> | 2010-12-14 02:59:59 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-12-14 02:59:59 +0000 |
commit | 8b2fe6dcbdf27b0df84ef4bdf514f9bc577c5804 (patch) | |
tree | 9816fbd1612d4cb872b44f996c47f67f9fc6470f /lldb/source/Expression/ClangUserExpression.cpp | |
parent | 12960558416a6797ea7504e7d9934bb11a5b1f42 (diff) | |
download | bcm5719-llvm-8b2fe6dcbdf27b0df84ef4bdf514f9bc577c5804.tar.gz bcm5719-llvm-8b2fe6dcbdf27b0df84ef4bdf514f9bc577c5804.zip |
Modified LLDB expressions to not have to JIT and run code just to see variable
values or persistent expression variables. Now if an expression consists of
a value that is a child of a variable, or of a persistent variable only, we
will create a value object for it and make a ValueObjectConstResult from it to
freeze the value (for program variables only, not persistent variables) and
avoid running JITed code. For everything else we still parse up and JIT code
and run it in the inferior.
There was also a lot of clean up in the expression code. I made the
ClangExpressionVariables be stored in collections of shared pointers instead
of in collections of objects. This will help stop a lot of copy constructors on
these large objects and also cleans up the code considerably. The persistent
clang expression variables were moved over to the Target to ensure they persist
across process executions.
Added the ability for lldb_private::Target objects to evaluate expressions.
We want to evaluate expressions at the target level in case we aren't running
yet, or we have just completed running. We still want to be able to access the
persistent expression variables between runs, and also evaluate constant
expressions.
Added extra logging to the dynamic loader plug-in for MacOSX. ModuleList objects
can now dump their contents with the UUID, arch and full paths being logged with
appropriate prefix values.
Thread hardened the Communication class a bit by making the connection auto_ptr
member into a shared pointer member and then making a local copy of the shared
pointer in each method that uses it to make sure another thread can't nuke the
connection object while it is being used by another thread.
Added a new file to the lldb/test/load_unload test that causes the test a.out file
to link to the libd.dylib file all the time. This will allow us to test using
the DYLD_LIBRARY_PATH environment variable after moving libd.dylib somewhere else.
llvm-svn: 121745
Diffstat (limited to 'lldb/source/Expression/ClangUserExpression.cpp')
-rw-r--r-- | lldb/source/Expression/ClangUserExpression.cpp | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index aa51106bce2..278cee773c1 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -271,7 +271,7 @@ ClangUserExpression::Parse (Stream &error_stream, m_dwarf_opcodes->SetByteOrder (lldb::eByteOrderHost); m_dwarf_opcodes->GetFlags ().Set (Stream::eBinary); - m_local_variables.reset(new ClangExpressionVariableStore()); + m_local_variables.reset(new ClangExpressionVariableList()); Error dwarf_error = parser.MakeDWARF (); @@ -422,7 +422,7 @@ ClangUserExpression::GetThreadPlanToExecuteJITExpression (Stream &error_stream, bool ClangUserExpression::FinalizeJITExecution (Stream &error_stream, ExecutionContext &exe_ctx, - ClangExpressionVariable *&result) + lldb::ClangExpressionVariableSP &result) { Error expr_error; @@ -454,12 +454,12 @@ ClangUserExpression::FinalizeJITExecution (Stream &error_stream, return true; } -Process::ExecutionResults +lldb::ExecutionResults ClangUserExpression::Execute (Stream &error_stream, ExecutionContext &exe_ctx, bool discard_on_error, ClangUserExpression::ClangUserExpressionSP &shared_ptr_to_me, - ClangExpressionVariable *&result) + lldb::ClangExpressionVariableSP &result) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -469,7 +469,7 @@ ClangUserExpression::Execute (Stream &error_stream, error_stream.Printf("We don't currently support executing DWARF expressions"); - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } else if (m_jit_addr != LLDB_INVALID_ADDRESS) { @@ -479,7 +479,7 @@ ClangUserExpression::Execute (Stream &error_stream, lldb::addr_t cmd_ptr = NULL; if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr)) - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; const bool stop_others = true; const bool try_all_threads = true; @@ -495,7 +495,7 @@ ClangUserExpression::Execute (Stream &error_stream, shared_ptr_to_me)); if (call_plan_sp == NULL || !call_plan_sp->ValidatePlan (NULL)) - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; call_plan_sp->SetPrivate(true); @@ -504,14 +504,18 @@ ClangUserExpression::Execute (Stream &error_stream, if (log) log->Printf("-- [ClangUserExpression::Execute] Execution of expression begins --"); - Process::ExecutionResults execution_result = - exe_ctx.process->RunThreadPlan (exe_ctx, call_plan_sp, stop_others, try_all_threads, discard_on_error, - single_thread_timeout_usec, error_stream); + lldb::ExecutionResults execution_result = exe_ctx.process->RunThreadPlan (exe_ctx, + call_plan_sp, + stop_others, + try_all_threads, + discard_on_error, + single_thread_timeout_usec, + error_stream); if (log) log->Printf("-- [ClangUserExpression::Execute] Execution of expression completed --"); - if (execution_result == Process::eExecutionInterrupted) + if (execution_result == lldb::eExecutionInterrupted) { if (discard_on_error) error_stream.Printf ("Expression execution was interrupted. The process has been returned to the state before execution."); @@ -520,21 +524,21 @@ ClangUserExpression::Execute (Stream &error_stream, return execution_result; } - else if (execution_result != Process::eExecutionCompleted) + else if (execution_result != lldb::eExecutionCompleted) { error_stream.Printf ("Couldn't execute function; result was %s\n", Process::ExecutionResultAsCString (execution_result)); return execution_result; } if (FinalizeJITExecution (error_stream, exe_ctx, result)) - return Process::eExecutionCompleted; + return lldb::eExecutionCompleted; else - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } else { error_stream.Printf("Expression can't be run; neither DWARF nor a JIT compiled function is present"); - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } } @@ -547,7 +551,7 @@ ClangUserExpression::DwarfOpcodeStream () return *m_dwarf_opcodes.get(); } -Process::ExecutionResults +lldb::ExecutionResults ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, bool discard_on_error, const char *expr_cstr, @@ -557,14 +561,14 @@ ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); Error error; - Process::ExecutionResults execution_results = Process::eExecutionSetupError; + lldb::ExecutionResults execution_results = lldb::eExecutionSetupError; if (exe_ctx.process == NULL) { error.SetErrorString ("Must have a process to evaluate expressions."); result_valobj_sp.reset (new ValueObjectConstResult (error)); - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } if (!exe_ctx.process->GetDynamicCheckers()) @@ -584,7 +588,7 @@ ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, error.SetErrorString (install_errors.GetString().c_str()); result_valobj_sp.reset (new ValueObjectConstResult (error)); - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } exe_ctx.process->SetDynamicCheckers(dynamic_checkers); @@ -609,7 +613,7 @@ ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, } else { - ClangExpressionVariable *expr_result = NULL; + lldb::ClangExpressionVariableSP expr_result; error_stream.GetString().clear(); @@ -621,7 +625,7 @@ ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, discard_on_error, user_expression_sp, expr_result); - if (execution_results != Process::eExecutionCompleted) + if (execution_results != lldb::eExecutionCompleted) { if (log) log->Printf("== [ClangUserExpression::Evaluate] Execution completed abnormally =="); @@ -633,14 +637,9 @@ ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, } else { - // TODO: seems weird to get a pointer to a result object back from - // a function. Do we own it? Feels like we do, but from looking at the - // code we don't. Might be best to make this a reference and state - // explicitly that we don't own it when we get a reference back from - // the execute? if (expr_result) { - result_valobj_sp = expr_result->GetExpressionResult (&exe_ctx); + result_valobj_sp = expr_result->GetValueObject(); if (log) log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with result %s ==", result_valobj_sp->GetValueAsCString(exe_ctx.GetBestExecutionContextScope())); |