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
This commit is contained in:
parent
a1b536a231
commit
dfc88a0338
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue