//------------------------------------------------------------------
IRExecutionUnit (std::auto_ptr<llvm::Module> &module_ap,
ConstString &name,
- lldb::ProcessSP process_sp,
+ const lldb::TargetSP &target_sp,
std::vector<std::string> &cpu_features);
//------------------------------------------------------------------
class IRMemoryMap
{
public:
- IRMemoryMap (lldb::ProcessSP process_sp);
IRMemoryMap (lldb::TargetSP target_sp);
~IRMemoryMap ();
lldb::ByteOrder GetByteOrder();
uint32_t GetAddressByteSize();
+ // This function can return NULL.
ExecutionContextScope *GetBestExecutionContextScope();
protected:
+ // This function should only be used if you know you are using the JIT.
+ // Any other cases should use GetBestExecutionContextScope().
lldb::ProcessWP GetProcessWP ()
{
return m_process_wp;
m_execution_unit.reset(new IRExecutionUnit(module_ap, // handed off here
function_name,
- exe_ctx.GetProcessSP(),
+ exe_ctx.GetTargetSP(),
m_compiler->getTargetOpts().Features));
ClangExpressionDeclMap *decl_map = m_expr.DeclMap(); // result can be NULL
IRExecutionUnit::IRExecutionUnit (std::auto_ptr<llvm::Module> &module_ap,
ConstString &name,
- lldb::ProcessSP process_sp,
+ const lldb::TargetSP &target_sp,
std::vector<std::string> &cpu_features) :
- IRMemoryMap(process_sp),
+ IRMemoryMap(target_sp),
m_module_ap(module_ap),
m_module(m_module_ap.get()),
m_cpu_features(cpu_features),
using namespace lldb_private;
-IRMemoryMap::IRMemoryMap (lldb::ProcessSP process_sp) :
- m_process_wp(process_sp),
- m_target_wp(process_sp->GetTarget().shared_from_this())
-{
-}
-
IRMemoryMap::IRMemoryMap (lldb::TargetSP target_sp) :
- m_process_wp(),
m_target_wp(target_sp)
{
+ if (target_sp)
+ m_process_wp = target_sp->GetProcessSP();
}
IRMemoryMap::~IRMemoryMap ()
m_variable_sp->GetName().AsCString());
}
- lldb::ValueObjectSP valobj_sp = ValueObjectVariable::Create(frame_sp.get(), m_variable_sp);
+ ExecutionContextScope *scope = frame_sp.get();
+
+ if (!scope)
+ scope = map.GetBestExecutionContextScope();
+
+ lldb::ValueObjectSP valobj_sp = ValueObjectVariable::Create(scope, m_variable_sp);
if (!valobj_sp)
{
if (m_temporary_allocation != LLDB_INVALID_ADDRESS)
{
- lldb::ValueObjectSP valobj_sp = ValueObjectVariable::Create(frame_sp.get(), m_variable_sp);
+ ExecutionContextScope *scope = frame_sp.get();
+
+ if (!scope)
+ scope = map.GetBestExecutionContextScope();
+
+ lldb::ValueObjectSP valobj_sp = ValueObjectVariable::Create(scope, m_variable_sp);
if (!valobj_sp)
{
Materializer::Dematerializer
Materializer::Materialize (lldb::StackFrameSP &frame_sp, lldb::ClangExpressionVariableSP &result_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &error)
{
+ ExecutionContextScope *exe_scope = frame_sp.get();
+
+ if (!exe_scope)
+ exe_scope = map.GetBestExecutionContextScope();
+
+ if (!exe_scope)
+ {
+ error.SetErrorToGenericError();
+ error.SetErrorString("Couldn't dematerialize: target doesn't exist");
+ }
+
for (EntityUP &entity_up : m_entities)
{
entity_up->Materialize(frame_sp, map, process_address, error);
{
lldb::StackFrameSP frame_sp = m_frame_wp.lock();
- if (!frame_sp)
+ ExecutionContextScope *exe_scope = m_map.GetBestExecutionContextScope();
+
+ if (!exe_scope)
{
error.SetErrorToGenericError();
- error.SetErrorString("Couldn't dematerialize: frame is gone");
+ error.SetErrorString("Couldn't dematerialize: target is gone");
}
else
{