diff options
author | Greg Clayton <gclayton@apple.com> | 2011-09-22 04:58:26 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-09-22 04:58:26 +0000 |
commit | c14ee32db561671a16759c8307d5391646cb87c4 (patch) | |
tree | 33eea53e3b30461a2452c79eca2e668aa9537500 /lldb/source/Expression/ClangUserExpression.cpp | |
parent | 3d10b95bf7f72dd7abbb1bb6a8412708a579d315 (diff) | |
download | bcm5719-llvm-c14ee32db561671a16759c8307d5391646cb87c4.tar.gz bcm5719-llvm-c14ee32db561671a16759c8307d5391646cb87c4.zip |
Converted the lldb_private::Process over to use the intrusive
shared pointers.
Changed the ExecutionContext over to use shared pointers for
the target, process, thread and frame since these objects can
easily go away at any time and any object that was holding onto
an ExecutionContext was running the risk of using a bad object.
Now that the shared pointers for target, process, thread and
frame are just a single pointer (they all use the instrusive
shared pointers) the execution context is much safer and still
the same size.
Made the shared pointers in the the ExecutionContext class protected
and made accessors for all of the various ways to get at the pointers,
references, and shared pointers.
llvm-svn: 140298
Diffstat (limited to 'lldb/source/Expression/ClangUserExpression.cpp')
-rw-r--r-- | lldb/source/Expression/ClangUserExpression.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index 194ad95a190..73ed043c26a 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -80,12 +80,13 @@ ClangUserExpression::ASTTransformer (clang::ASTConsumer *passthrough) void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx) { - m_target = exe_ctx.target; + m_target = exe_ctx.GetTargetPtr(); - if (!exe_ctx.frame) + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame == NULL) return; - SymbolContext sym_ctx = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextFunction); + SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction); if (!sym_ctx.function) return; @@ -246,7 +247,7 @@ ClangUserExpression::Parse (Stream &error_stream, // Set up the target and compiler // - Target *target = exe_ctx.target; + Target *target = exe_ctx.GetTargetPtr(); if (!target) { @@ -268,7 +269,8 @@ ClangUserExpression::Parse (Stream &error_stream, return false; } - ClangExpressionParser parser(exe_ctx.process, *this); + Process *process = exe_ctx.GetProcessPtr(); + ClangExpressionParser parser(process, *this); unsigned num_errors = parser.Parse (error_stream); @@ -285,8 +287,8 @@ ClangUserExpression::Parse (Stream &error_stream, // Prepare the output of the parser for execution, evaluating it statically if possible // - if (execution_policy != eExecutionPolicyNever && exe_ctx.process) - m_data_allocator.reset(new ProcessDataAllocator(*exe_ctx.process)); + if (execution_policy != eExecutionPolicyNever && process) + m_data_allocator.reset(new ProcessDataAllocator(*process)); Error jit_error = parser.PrepareForExecution (m_jit_alloc, m_jit_start_addr, @@ -309,8 +311,8 @@ ClangUserExpression::Parse (Stream &error_stream, if (jit_error.Success()) { - if (exe_ctx.process && m_jit_alloc != LLDB_INVALID_ADDRESS) - m_jit_process_sp = exe_ctx.process->GetSP(); + if (process && m_jit_alloc != LLDB_INVALID_ADDRESS) + m_jit_process_sp = process->GetSP(); return true; } else @@ -505,7 +507,7 @@ ClangUserExpression::Execute (Stream &error_stream, const bool try_all_threads = true; Address wrapper_address (NULL, m_jit_start_addr); - lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (*(exe_ctx.thread), + lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(), wrapper_address, struct_address, stop_others, @@ -526,13 +528,13 @@ ClangUserExpression::Execute (Stream &error_stream, if (log) log->Printf("-- [ClangUserExpression::Execute] Execution of expression begins --"); - 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); + ExecutionResults execution_result = exe_ctx.GetProcessRef().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 --"); @@ -602,7 +604,9 @@ ClangUserExpression::EvaluateWithError (ExecutionContext &exe_ctx, ExecutionResults execution_results = eExecutionSetupError; - if (exe_ctx.process == NULL || exe_ctx.process->GetState() != lldb::eStateStopped) + Process *process = exe_ctx.GetProcessPtr(); + + if (process == NULL || process->GetState() != lldb::eStateStopped) { if (execution_policy == eExecutionPolicyAlways) { @@ -615,7 +619,7 @@ ClangUserExpression::EvaluateWithError (ExecutionContext &exe_ctx, } } - if (exe_ctx.process == NULL || !exe_ctx.process->CanJIT()) + if (process == NULL || !process->CanJIT()) execution_policy = eExecutionPolicyNever; ClangUserExpressionSP user_expression_sp (new ClangUserExpression (expr_cstr, expr_prefix)); |