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.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@140298 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 3549196..e674565 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -463,9 +463,9 @@
if (decl_map)
{
Stream *error_stream = NULL;
-
- if (exe_ctx.target)
- error_stream = &exe_ctx.target->GetDebugger().GetErrorStream();
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target)
+ error_stream = &target->GetDebugger().GetErrorStream();
IRForTarget ir_for_target(decl_map,
m_expr.NeedsVariableResolution(),
@@ -489,7 +489,9 @@
return err;
}
- if (!exe_ctx.process || execution_policy == eExecutionPolicyNever)
+ Process *process = exe_ctx.GetProcessPtr();
+
+ if (!process || execution_policy == eExecutionPolicyNever)
{
err.SetErrorToGenericError();
err.SetErrorString("Execution needed to run in the target, but the target can't be run");
@@ -498,9 +500,9 @@
if (execution_policy != eExecutionPolicyNever &&
m_expr.NeedsValidation() &&
- exe_ctx.process)
+ process)
{
- if (!exe_ctx.process->GetDynamicCheckers())
+ if (!process->GetDynamicCheckers())
{
DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
@@ -516,13 +518,13 @@
return err;
}
- exe_ctx.process->SetDynamicCheckers(dynamic_checkers);
+ process->SetDynamicCheckers(dynamic_checkers);
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers ==");
}
- IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), function_name.c_str());
+ IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(), function_name.c_str());
if (!ir_dynamic_checks.runOnModule(*module))
{
@@ -586,9 +588,9 @@
m_jitted_functions.push_back (ClangExpressionParser::JittedFunction(function_name.c_str(), (lldb::addr_t)fun_ptr));
- ExecutionContext &exc_context(exe_ctx);
-
- if (exc_context.process == NULL)
+
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process == NULL)
{
err.SetErrorToGenericError();
err.SetErrorString("Couldn't write the JIT compiled code into the target because there is no target");
@@ -615,7 +617,7 @@
}
Error alloc_error;
- func_allocation_addr = exc_context.process->AllocateMemory (alloc_size,
+ func_allocation_addr = process->AllocateMemory (alloc_size,
lldb::ePermissionsReadable|lldb::ePermissionsExecutable,
alloc_error);
@@ -636,7 +638,7 @@
Error write_error;
- if (exc_context.process->WriteMemory(cursor, (void *) lstart, size, write_error) != size)
+ if (process->WriteMemory(cursor, (void *) lstart, size, write_error) != size)
{
err.SetErrorToGenericError();
err.SetErrorStringWithFormat("Couldn't copy JIT code for function into the target: %s", write_error.AsCString("unknown error"));
@@ -731,7 +733,8 @@
if (log)
log->Printf("Function's code range is [0x%llx-0x%llx]", func_range.first, func_range.second);
- if (!exe_ctx.target)
+ Target *target = exe_ctx.GetTargetPtr();
+ if (!target)
{
ret.SetErrorToGenericError();
ret.SetErrorString("Couldn't find the target");
@@ -739,8 +742,9 @@
lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second - func_remote_addr, 0));
+ Process *process = exe_ctx.GetProcessPtr();
Error err;
- exe_ctx.process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err);
+ process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err);
if (!err.Success())
{
@@ -749,7 +753,7 @@
return ret;
}
- ArchSpec arch(exe_ctx.target->GetArchitecture());
+ ArchSpec arch(target->GetArchitecture());
Disassembler *disassembler = Disassembler::FindPlugin(arch, NULL);
@@ -760,7 +764,7 @@
return ret;
}
- if (!exe_ctx.process)
+ if (!process)
{
ret.SetErrorToGenericError();
ret.SetErrorString("Couldn't find the process");
@@ -768,8 +772,8 @@
}
DataExtractor extractor(buffer_sp,
- exe_ctx.process->GetByteOrder(),
- exe_ctx.target->GetArchitecture().GetAddressByteSize());
+ process->GetByteOrder(),
+ target->GetArchitecture().GetAddressByteSize());
if (log)
{