diff options
author | Enrico Granata <egranata@apple.com> | 2012-09-18 00:08:47 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2012-09-18 00:08:47 +0000 |
commit | dfc88a0338fece6483ee5c6214f86ea77a91451a (patch) | |
tree | 6af5fdd7ff07d9697d57ff1e57a807aca49d7aa5 | |
parent | a1b536a231bef1e623f031f39b867b50bfdbf8c9 (diff) | |
download | bcm5719-llvm-dfc88a0338fece6483ee5c6214f86ea77a91451a.tar.gz bcm5719-llvm-dfc88a0338fece6483ee5c6214f86ea77a91451a.zip |
Making ClangExpression hold on to a WP to the Process instead of a SP. This fix should enable us to have per-process maps of ClangExpressions without fear of keeping the process alive forever
llvm-svn: 164082
-rw-r--r-- | lldb/include/lldb/Expression/ClangExpression.h | 10 | ||||
-rw-r--r-- | lldb/source/Expression/ClangFunction.cpp | 40 | ||||
-rw-r--r-- | lldb/source/Expression/ClangUserExpression.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Expression/ClangUtilityFunction.cpp | 2 |
4 files changed, 35 insertions, 19 deletions
diff --git a/lldb/include/lldb/Expression/ClangExpression.h b/lldb/include/lldb/Expression/ClangExpression.h index b870dae07c6..ac29024804e 100644 --- a/lldb/include/lldb/Expression/ClangExpression.h +++ b/lldb/include/lldb/Expression/ClangExpression.h @@ -47,7 +47,7 @@ public: }; ClangExpression () : - m_jit_process_sp(), + m_jit_process_wp(), m_jit_alloc (LLDB_INVALID_ADDRESS), m_jit_start_addr (LLDB_INVALID_ADDRESS), m_jit_end_addr (LLDB_INVALID_ADDRESS) @@ -143,13 +143,13 @@ public: void DeallocateJITFunction () { - if (m_jit_process_sp && m_jit_alloc != LLDB_INVALID_ADDRESS) + lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock()); + if (jit_process_sp && m_jit_alloc != LLDB_INVALID_ADDRESS) { - m_jit_process_sp->DeallocateMemory (m_jit_alloc); + jit_process_sp->DeallocateMemory (m_jit_alloc); // If this process is ever used for anything else, we can not clear it // here. For now it is only used in order to deallocate any code if // m_jit_alloc is a valid address. - m_jit_process_sp.reset(); m_jit_alloc = LLDB_INVALID_ADDRESS; } } @@ -166,7 +166,7 @@ public: protected: - lldb::ProcessSP m_jit_process_sp; + lldb::ProcessWP m_jit_process_wp; lldb::addr_t m_jit_alloc; ///< The address of the block containing JITted code. LLDB_INVALID_ADDRESS if invalid. lldb::addr_t m_jit_start_addr; ///< The address of the JITted function within the JIT allocation. LLDB_INVALID_ADDRESS if invalid. lldb::addr_t m_jit_end_addr; ///< The address of the JITted function within the JIT allocation. LLDB_INVALID_ADDRESS if invalid. diff --git a/lldb/source/Expression/ClangFunction.cpp b/lldb/source/Expression/ClangFunction.cpp index 7a3d6cd12b6..54c0d4a9d26 100644 --- a/lldb/source/Expression/ClangFunction.cpp +++ b/lldb/source/Expression/ClangFunction.cpp @@ -66,9 +66,9 @@ ClangFunction::ClangFunction m_compiled (false), m_JITted (false) { - m_jit_process_sp = exe_scope.CalculateProcess(); + m_jit_process_wp = lldb::ProcessWP(exe_scope.CalculateProcess()); // Can't make a ClangFunction without a process. - assert (m_jit_process_sp); + assert (m_jit_process_wp.lock()); } ClangFunction::ClangFunction @@ -89,9 +89,9 @@ ClangFunction::ClangFunction m_compiled (false), m_JITted (false) { - m_jit_process_sp = exe_scope.CalculateProcess(); + m_jit_process_wp = lldb::ProcessWP(exe_scope.CalculateProcess()); // Can't make a ClangFunction without a process. - assert (m_jit_process_sp); + assert (m_jit_process_wp.lock()); m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress(); m_function_return_qual_type = m_function_ptr->GetReturnClangType(); @@ -219,10 +219,19 @@ ClangFunction::CompileFunction (Stream &errors) log->Printf ("Expression: \n\n%s\n\n", m_wrapper_function_text.c_str()); // Okay, now compile this expression - - m_parser.reset(new ClangExpressionParser(m_jit_process_sp.get(), *this)); - num_errors = m_parser->Parse (errors); + lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock()); + if (jit_process_sp) + { + m_parser.reset(new ClangExpressionParser(jit_process_sp.get(), *this)); + + num_errors = m_parser->Parse (errors); + } + else + { + errors.Printf("no process - unable to inject function"); + num_errors = 1; + } m_compiled = (num_errors == 0); @@ -239,8 +248,10 @@ ClangFunction::WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors) if (!process) return false; - - if (process != m_jit_process_sp.get()) + + lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock()); + + if (process != jit_process_sp.get()) return false; if (!m_compiled) @@ -265,7 +276,7 @@ ClangFunction::WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors) if (!jit_error.Success()) return false; if (process && m_jit_alloc != LLDB_INVALID_ADDRESS) - m_jit_process_sp = process->shared_from_this(); + m_jit_process_wp = lldb::ProcessWP(process->shared_from_this()); return true; } @@ -302,7 +313,9 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx, if (process == NULL) return return_value; - if (process != m_jit_process_sp.get()) + lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock()); + + if (process != jit_process_sp.get()) return false; if (args_addr_ref == LLDB_INVALID_ADDRESS) @@ -426,7 +439,10 @@ ClangFunction::FetchFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t arg if (process == NULL) return false; - if (process != m_jit_process_sp.get()) + + lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock()); + + if (process != jit_process_sp.get()) return false; Error error; diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index 194f5ab87b6..877c8d7cabc 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -351,7 +351,7 @@ ClangUserExpression::Parse (Stream &error_stream, if (jit_error.Success()) { if (process && m_jit_alloc != LLDB_INVALID_ADDRESS) - m_jit_process_sp = process->shared_from_this(); + m_jit_process_wp = lldb::ProcessWP(process->shared_from_this()); return true; } else diff --git a/lldb/source/Expression/ClangUtilityFunction.cpp b/lldb/source/Expression/ClangUtilityFunction.cpp index 78c3c16e306..b2f13f11f8a 100644 --- a/lldb/source/Expression/ClangUtilityFunction.cpp +++ b/lldb/source/Expression/ClangUtilityFunction.cpp @@ -148,7 +148,7 @@ ClangUtilityFunction::Install (Stream &error_stream, } if (m_jit_start_addr != LLDB_INVALID_ADDRESS) - m_jit_process_sp = process->shared_from_this(); + m_jit_process_wp = lldb::ProcessWP(process->shared_from_this()); #if 0 // jingham: look here |