summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Expression/ClangExpressionDeclMap.h4
-rw-r--r--lldb/include/lldb/Target/ExecutionContext.h94
-rw-r--r--lldb/include/lldb/Target/Process.h1
-rw-r--r--lldb/include/lldb/lldb-forward-rtti.h2
-rw-r--r--lldb/lldb.xcodeproj/project.pbxproj2
-rw-r--r--lldb/source/API/SBBreakpoint.cpp14
-rw-r--r--lldb/source/API/SBFunction.cpp2
-rw-r--r--lldb/source/API/SBInstruction.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointOptions.cpp9
-rw-r--r--lldb/source/Commands/CommandObjectArgs.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectBreakpointCommand.cpp5
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.cpp25
-rw-r--r--lldb/source/Commands/CommandObjectExpression.cpp48
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp58
-rw-r--r--lldb/source/Commands/CommandObjectMemory.cpp28
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp35
-rw-r--r--lldb/source/Commands/CommandObjectRegister.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectSource.cpp8
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp28
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp38
-rw-r--r--lldb/source/Core/Address.cpp5
-rw-r--r--lldb/source/Core/Debugger.cpp240
-rw-r--r--lldb/source/Core/Disassembler.cpp96
-rw-r--r--lldb/source/Core/FormatClasses.cpp5
-rw-r--r--lldb/source/Core/SearchFilter.cpp2
-rw-r--r--lldb/source/Core/Value.cpp14
-rw-r--r--lldb/source/Core/ValueObject.cpp29
-rw-r--r--lldb/source/Core/ValueObjectDynamicValue.cpp8
-rw-r--r--lldb/source/Core/ValueObjectMemory.cpp11
-rw-r--r--lldb/source/Core/ValueObjectVariable.cpp14
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp289
-rw-r--r--lldb/source/Expression/ClangExpressionParser.cpp42
-rw-r--r--lldb/source/Expression/ClangFunction.cpp38
-rw-r--r--lldb/source/Expression/ClangUserExpression.cpp42
-rw-r--r--lldb/source/Expression/ClangUtilityFunction.cpp10
-rw-r--r--lldb/source/Expression/DWARFExpression.cpp70
-rw-r--r--lldb/source/Expression/IRDynamicChecks.cpp6
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp37
-rw-r--r--lldb/source/Interpreter/CommandObject.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp2
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp15
-rw-r--r--lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp14
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp4
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp13
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp9
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp16
-rw-r--r--lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp2
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp8
-rw-r--r--lldb/source/Symbol/ClangASTType.cpp73
-rw-r--r--lldb/source/Symbol/Type.cpp17
-rw-r--r--lldb/source/Target/ExecutionContext.cpp200
-rw-r--r--lldb/source/Target/Process.cpp65
-rw-r--r--lldb/source/Target/StackFrame.cpp2
-rw-r--r--lldb/source/Target/StopInfo.cpp2
-rw-r--r--lldb/source/Target/Target.cpp17
-rw-r--r--lldb/source/Target/Thread.cpp13
-rw-r--r--lldb/source/Target/ThreadPlanTestCondition.cpp2
59 files changed, 1111 insertions, 736 deletions
diff --git a/lldb/include/lldb/Expression/ClangExpressionDeclMap.h b/lldb/include/lldb/Expression/ClangExpressionDeclMap.h
index dcea151eba8..4ea5b046bda 100644
--- a/lldb/include/lldb/Expression/ClangExpressionDeclMap.h
+++ b/lldb/include/lldb/Expression/ClangExpressionDeclMap.h
@@ -701,8 +701,8 @@ private:
Target *
GetTarget()
{
- if (m_exe_ctx && m_exe_ctx->target)
- return m_exe_ctx->target;
+ if (m_exe_ctx && m_exe_ctx->GetTargetPtr())
+ return m_exe_ctx->GetTargetPtr();
else if (m_sym_ctx.target_sp)
m_sym_ctx.target_sp.get();
return NULL;
diff --git a/lldb/include/lldb/Target/ExecutionContext.h b/lldb/include/lldb/Target/ExecutionContext.h
index 23500f9f7a6..4022fee2792 100644
--- a/lldb/include/lldb/Target/ExecutionContext.h
+++ b/lldb/include/lldb/Target/ExecutionContext.h
@@ -39,6 +39,10 @@ public:
//------------------------------------------------------------------
ExecutionContext();
+ ExecutionContext (const ExecutionContext &rhs);
+
+ ExecutionContext &
+ operator =(const ExecutionContext &rhs);
ExecutionContext (Target* t, bool fill_current_process_thread_frame = true);
//------------------------------------------------------------------
@@ -64,6 +68,7 @@ public:
ExecutionContext (ExecutionContextScope &exe_scope);
+ ~ExecutionContext();
//------------------------------------------------------------------
/// Clear the object's state.
///
@@ -76,20 +81,95 @@ public:
RegisterContext *
GetRegisterContext () const;
-
ExecutionContextScope *
GetBestExecutionContextScope () const;
-
+
+ Target *
+ GetTargetPtr () const;
+
Process *
- GetProcess () const;
+ GetProcessPtr () const;
+
+ Thread *
+ GetThreadPtr () const
+ {
+ return m_thread_sp.get();
+ }
+
+ StackFrame *
+ GetFramePtr () const
+ {
+ return m_frame_sp.get();
+ }
+
+ Target &
+ GetTargetRef () const;
+
+ Process &
+ GetProcessRef () const;
+
+ Thread &
+ GetThreadRef () const;
+
+ StackFrame &
+ GetFrameRef () const;
+
+ const lldb::TargetSP &
+ GetTargetSP ()
+ {
+ return m_target_sp;
+ }
+
+ const lldb::ProcessSP &
+ GetProcessSP ()
+ {
+ return m_process_sp;
+ }
+
+ const lldb::ThreadSP &
+ GetThreadSP ()
+ {
+ return m_thread_sp;
+ }
+
+ const lldb::StackFrameSP &
+ GetFrameSP ()
+ {
+ return m_frame_sp;
+ }
+
+ void
+ SetTargetSP (const lldb::TargetSP &target_sp);
+
+ void
+ SetProcessSP (const lldb::ProcessSP &process_sp);
+
+ void
+ SetThreadSP (const lldb::ThreadSP &thread_sp);
+
+ void
+ SetFrameSP (const lldb::StackFrameSP &frame_sp);
+
+ void
+ SetTargetPtr (Target* target);
+
+ void
+ SetProcessPtr (Process *process);
+
+ void
+ SetThreadPtr (Thread *thread);
+
+ void
+ SetFramePtr (StackFrame *frame);
+protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
- Target *target; ///< The target that owns the process/thread/frame
- Process *process; ///< The process that owns the thread/frame
- Thread *thread; ///< The thread that owns the frame
- StackFrame *frame; ///< The stack frame in thread.
+ lldb::TargetSP m_target_sp; ///< The target that owns the process/thread/frame
+ lldb::ProcessSP m_process_sp; ///< The process that owns the thread/frame
+ lldb::ThreadSP m_thread_sp; ///< The thread that owns the frame
+ lldb::StackFrameSP m_frame_sp; ///< The stack frame in thread.
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index fbf85a338b3..3914a72f97f 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -994,6 +994,7 @@ inline bool operator!= (const ProcessModID &lhs, const ProcessModID &rhs)
/// @brief A plug-in interface definition class for debugging a process.
//----------------------------------------------------------------------
class Process :
+ public ReferenceCountedBaseVirtual<Process>,
public UserID,
public Broadcaster,
public ExecutionContextScope,
diff --git a/lldb/include/lldb/lldb-forward-rtti.h b/lldb/include/lldb/lldb-forward-rtti.h
index c962a68b693..d935d6d5b7e 100644
--- a/lldb/include/lldb/lldb-forward-rtti.h
+++ b/lldb/include/lldb/lldb-forward-rtti.h
@@ -54,7 +54,7 @@ namespace lldb {
typedef IntrusiveSharedPtr<lldb_private::ObjectFile>::Type ObjectFileSP;
typedef SharedPtr<lldb_private::OptionValue>::Type OptionValueSP;
typedef SharedPtr<lldb_private::Platform>::Type PlatformSP;
- typedef SharedPtr<lldb_private::Process>::Type ProcessSP;
+ typedef IntrusiveSharedPtr<lldb_private::Process>::Type ProcessSP;
typedef SharedPtr<lldb_private::RegisterContext>::Type RegisterContextSP;
typedef SharedPtr<lldb_private::RegularExpression>::Type RegularExpressionSP;
typedef SharedPtr<lldb_private::Section>::Type SectionSP;
diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj
index 28b0c4f893a..166b0a4ce51 100644
--- a/lldb/lldb.xcodeproj/project.pbxproj
+++ b/lldb/lldb.xcodeproj/project.pbxproj
@@ -410,7 +410,7 @@
4CCA645613B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CCA644813B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp */; };
4CCA645813B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CCA644A13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */; };
4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */; };
- 4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CF52AF41428291E0051E832 /* SBFileSpecList.h */; };
+ 4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CF52AF41428291E0051E832 /* SBFileSpecList.h */; settings = {ATTRIBUTES = (Public, ); }; };
4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */; };
94031A9E13CF486700DCFF3C /* InputReaderEZ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */; };
9415F61813B2C0EF00A52B36 /* FormatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */; };
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 9f2e3a1810c..5e3f3d7822a 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -487,22 +487,24 @@ SBBreakpoint::PrivateBreakpointHitCallback
lldb::user_id_t break_loc_id
)
{
- BreakpointSP bp_sp(ctx->exe_ctx.target->GetBreakpointList().FindBreakpointByID(break_id));
+ BreakpointSP bp_sp(ctx->exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id));
if (baton && bp_sp)
{
CallbackData *data = (CallbackData *)baton;
lldb_private::Breakpoint *bp = bp_sp.get();
if (bp && data->callback)
{
- if (ctx->exe_ctx.process)
+ Process *process = ctx->exe_ctx.GetProcessPtr();
+ if (process)
{
- SBProcess sb_process (ctx->exe_ctx.process->GetSP());
+ SBProcess sb_process (process->GetSP());
SBThread sb_thread;
SBBreakpointLocation sb_location;
assert (bp_sp);
sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id));
- if (ctx->exe_ctx.thread)
- sb_thread.SetThread(ctx->exe_ctx.thread->GetSP());
+ Thread *thread = ctx->exe_ctx.GetThreadPtr();
+ if (thread)
+ sb_thread.SetThread(thread->GetSP());
return data->callback (data->callback_baton,
sb_process,
@@ -522,7 +524,7 @@ SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton)
if (log)
log->Printf ("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)", m_opaque_sp.get(), callback, baton);
- if (m_opaque_sp.get())
+ if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton));
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index de9f6ae8a86..e037f83e8da 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -131,7 +131,7 @@ SBFunction::GetInstructions (SBTarget target)
{
api_locker.Reset (target->GetAPIMutex().GetMutex());
target->CalculateExecutionContext (exe_ctx);
- exe_ctx.process = target->GetProcessSP().get();
+ exe_ctx.SetProcessSP(target->GetProcessSP());
}
Module *module = m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule();
if (module)
diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp
index 0a5594a5a97..0be59af2f98 100644
--- a/lldb/source/API/SBInstruction.cpp
+++ b/lldb/source/API/SBInstruction.cpp
@@ -122,7 +122,7 @@ SBInstruction::EmulateWithFrame (lldb::SBFrame &frame, uint32_t evaluate_options
{
lldb_private::ExecutionContext exe_ctx;
frame->CalculateExecutionContext (exe_ctx);
- lldb_private::Target *target = exe_ctx.target;
+ lldb_private::Target *target = exe_ctx.GetTargetPtr();
lldb_private::ArchSpec arch = target->GetArchitecture();
return m_opaque_sp->Emulate (arch,
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp
index df41339ab8f..16e710121b7 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -180,7 +180,8 @@ BreakpointOptions::GetThreadPlanToTestCondition (ExecutionContext &exe_ctx,
return NULL;
// FIXME: I shouldn't have to do this, the process should handle it for me:
- if (!exe_ctx.process->GetDynamicCheckers())
+ Process *process = exe_ctx.GetProcessPtr();
+ if (!process->GetDynamicCheckers())
{
DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
@@ -192,11 +193,11 @@ BreakpointOptions::GetThreadPlanToTestCondition (ExecutionContext &exe_ctx,
return NULL;
}
- exe_ctx.process->SetDynamicCheckers(dynamic_checkers);
+ process->SetDynamicCheckers(dynamic_checkers);
}
// Get the boolean type from the process's scratch AST context
- ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext();
+ ClangASTContext *ast_context = exe_ctx.GetTargetRef().GetScratchClangASTContext();
TypeFromUser bool_type(ast_context->GetBuiltInType_bool(), ast_context->getASTContext());
const bool keep_in_memory = false;
@@ -209,7 +210,7 @@ BreakpointOptions::GetThreadPlanToTestCondition (ExecutionContext &exe_ctx,
// FIXME: When we can execute static expressions without running the target, we should check that here,
// and return something to indicate we should stop or just continue.
- ThreadPlan *new_plan = new ThreadPlanTestCondition (*exe_ctx.thread,
+ ThreadPlan *new_plan = new ThreadPlanTestCondition (exe_ctx.GetThreadRef(),
exe_ctx,
m_condition_ap.get(),
break_loc_sp,
diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp
index bfa1006d2f8..c0f9454b4ba 100644
--- a/lldb/source/Commands/CommandObjectArgs.cpp
+++ b/lldb/source/Commands/CommandObjectArgs.cpp
@@ -105,7 +105,7 @@ CommandObjectArgs::Execute
ConstString target_triple;
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (!process)
{
result.AppendError ("Args found no process.");
@@ -131,7 +131,7 @@ CommandObjectArgs::Execute
return false;
}
- Thread *thread = m_interpreter.GetExecutionContext ().thread;
+ Thread *thread = m_interpreter.GetExecutionContext ().GetThreadPtr();
if (!thread)
{
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index cc2051d3184..f528dfd1047 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -293,7 +293,7 @@ CommandObjectBreakpointSet::ChooseFile (Target *target, FileSpec &file, CommandR
// Then use the current stack frame's file.
if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
{
- StackFrame *cur_frame = m_interpreter.GetExecutionContext().frame;
+ StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr();
if (cur_frame == NULL)
{
result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame.");
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index c68f54cdf25..5130a2f86be 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -803,10 +803,11 @@ CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction
if (commands.GetSize() > 0)
{
- if (context->exe_ctx.target)
+ Target *target = context->exe_ctx.GetTargetPtr();
+ if (target)
{
CommandReturnObject result;
- Debugger &debugger = context->exe_ctx.target->GetDebugger();
+ Debugger &debugger = target->GetDebugger();
// Rig up the results secondary output stream to the debugger's, so the output will come out synchronously
// if the debugger is set up that way.
diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 8115a87a13b..5c7b4856429 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -314,15 +314,16 @@ CommandObjectDisassemble::Execute
else
{
AddressRange range;
+ StackFrame *frame = exe_ctx.GetFramePtr();
if (m_options.frame_line)
{
- if (exe_ctx.frame == NULL)
+ if (frame == NULL)
{
result.AppendError ("Cannot disassemble around the current line without a selected frame.\n");
result.SetStatus (eReturnStatusFailed);
return false;
}
- LineEntry pc_line_entry (exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
+ LineEntry pc_line_entry (frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
if (pc_line_entry.IsValid())
{
range = pc_line_entry.range;
@@ -335,13 +336,13 @@ CommandObjectDisassemble::Execute
}
else if (m_options.cur_function)
{
- if (exe_ctx.frame == NULL)
+ if (frame == NULL)
{
result.AppendError ("Cannot disassemble around the current function without a selected frame.\n");
result.SetStatus (eReturnStatusFailed);
return false;
}
- Symbol *symbol = exe_ctx.frame->GetSymbolContext(eSymbolContextSymbol).symbol;
+ Symbol *symbol = frame->GetSymbolContext(eSymbolContextSymbol).symbol;
if (symbol)
range = symbol->GetAddressRangeRef();
}
@@ -352,13 +353,13 @@ CommandObjectDisassemble::Execute
{
if (m_options.at_pc)
{
- if (exe_ctx.frame == NULL)
+ if (frame == NULL)
{
result.AppendError ("Cannot disassemble around the current PC without a selected frame.\n");
result.SetStatus (eReturnStatusFailed);
return false;
}
- range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress();
+ range.GetBaseAddress() = frame->GetFrameCodeAddress();
if (m_options.num_instructions == 0)
{
// Disassembling at the PC always disassembles some number of instructions (not the whole function).
@@ -389,15 +390,15 @@ CommandObjectDisassemble::Execute
if (!range.GetBaseAddress().IsValid())
{
// The default action is to disassemble the current frame function.
- if (exe_ctx.frame)
+ if (frame)
{
- SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol));
+ SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol));
if (sc.function)
range.GetBaseAddress() = sc.function->GetAddressRange().GetBaseAddress();
else if (sc.symbol && sc.symbol->GetAddressRangePtr())
range.GetBaseAddress() = sc.symbol->GetAddressRangePtr()->GetBaseAddress();
else
- range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress();
+ range.GetBaseAddress() = frame->GetFrameCodeAddress();
}
if (!range.GetBaseAddress().IsValid())
@@ -431,15 +432,15 @@ CommandObjectDisassemble::Execute
if (!range.GetBaseAddress().IsValid())
{
// The default action is to disassemble the current frame function.
- if (exe_ctx.frame)
+ if (frame)
{
- SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol));
+ SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol));
if (sc.function)
range = sc.function->GetAddressRange();
else if (sc.symbol && sc.symbol->GetAddressRangePtr())
range = *sc.symbol->GetAddressRangePtr();
else
- range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress();
+ range.GetBaseAddress() = frame->GetFrameCodeAddress();
}
else
{
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index cd6474c658e..2bacdbbba02 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -271,7 +271,8 @@ CommandObjectExpression::EvaluateExpression
CommandReturnObject *result
)
{
- if (m_exe_ctx.target)
+ Target *target = m_exe_ctx.GetTargetPtr();
+ if (target)
{
lldb::ValueObjectSP result_valobj_sp;
@@ -283,7 +284,7 @@ CommandObjectExpression::EvaluateExpression
switch (m_options.use_dynamic)
{
case eLazyBoolCalculate:
- use_dynamic = m_exe_ctx.target->GetPreferDynamicValue();
+ use_dynamic = target->GetPreferDynamicValue();
break;
case eLazyBoolYes:
use_dynamic = lldb::eDynamicCanRunTarget;
@@ -293,34 +294,39 @@ CommandObjectExpression::EvaluateExpression
break;
}
- exe_results = m_exe_ctx.target->EvaluateExpression(expr,
- m_exe_ctx.frame,
- eExecutionPolicyOnlyWhenNeeded,
- m_options.unwind_on_error,
- keep_in_memory,
- use_dynamic,
- result_valobj_sp);
+ exe_results = target->EvaluateExpression (expr,
+ m_exe_ctx.GetFramePtr(),
+ eExecutionPolicyOnlyWhenNeeded,
+ m_options.unwind_on_error,
+ keep_in_memory,
+ use_dynamic,
+ result_valobj_sp);
if (exe_results == eExecutionInterrupted && !m_options.unwind_on_error)
{
uint32_t start_frame = 0;
uint32_t num_frames = 1;
uint32_t num_frames_with_source = 0;
- if (m_exe_ctx.thread)
+ Thread *thread = m_exe_ctx.GetThreadPtr();
+ if (thread)
{
- m_exe_ctx.thread->GetStatus (result->GetOutputStream(),
- start_frame,
- num_frames,
- num_frames_with_source);
+ thread->GetStatus (result->GetOutputStream(),
+ start_frame,
+ num_frames,
+ num_frames_with_source);
}
- else if (m_exe_ctx.process)
+ else
{
- bool only_threads_with_stop_reason = true;
- m_exe_ctx.process->GetThreadStatus (result->GetOutputStream(),
- only_threads_with_stop_reason,
- start_frame,
- num_frames,
- num_frames_with_source);
+ Process *process = m_exe_ctx.GetProcessPtr();
+ if (process)
+ {
+ bool only_threads_with_stop_reason = true;
+ process->GetThreadStatus (result->GetOutputStream(),
+ only_threads_with_stop_reason,
+ start_frame,
+ num_frames,
+ num_frames_with_source);
+ }
}
}
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 4982bfb55a4..555afc3491e 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -74,9 +74,10 @@ public:
CommandReturnObject &result)
{
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- if (exe_ctx.frame)
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (frame)
{
- exe_ctx.frame->DumpUsingSettingsFormat (&result.GetOutputStream());
+ frame->DumpUsingSettingsFormat (&result.GetOutputStream());
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
@@ -192,14 +193,15 @@ public:
CommandReturnObject &result)
{
ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
- if (exe_ctx.thread)
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (thread)
{
- const uint32_t num_frames = exe_ctx.thread->GetStackFrameCount();
+ const uint32_t num_frames = thread->GetStackFrameCount();
uint32_t frame_idx = UINT32_MAX;
if (m_options.relative_frame_offset != INT32_MIN)
{
// The one and only argument is a signed relative frame index
- frame_idx = exe_ctx.thread->GetSelectedFrameIndex ();
+ frame_idx = thread->GetSelectedFrameIndex ();
if (frame_idx == UINT32_MAX)
frame_idx = 0;
@@ -254,13 +256,13 @@ public:
if (frame_idx < num_frames)
{
- exe_ctx.thread->SetSelectedFrameByIndex (frame_idx);
- exe_ctx.frame = exe_ctx.thread->GetSelectedFrame ().get();
-
- if (exe_ctx.frame)
+ thread->SetSelectedFrameByIndex (frame_idx);
+ exe_ctx.SetFrameSP(thread->GetSelectedFrame ());
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (frame)
{
bool already_shown = false;
- SymbolContext frame_sc(exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry));
+ SymbolContext frame_sc(frame->GetSymbolContext(eSymbolContextLineEntry));
if (m_interpreter.GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0)
{
already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line);
@@ -270,11 +272,11 @@ public:
bool show_source = !already_shown;
uint32_t source_lines_before = 3;
uint32_t source_lines_after = 3;
- if (exe_ctx.frame->GetStatus(result.GetOutputStream(),
- show_frame_info,
- show_source,
- source_lines_before,
- source_lines_after))
+ if (frame->GetStatus (result.GetOutputStream(),
+ show_frame_info,
+ show_source,
+ source_lines_before,
+ source_lines_after))
{
result.SetStatus (eReturnStatusSuccessFinishResult);
return result.Succeeded();
@@ -369,7 +371,8 @@ public:
)
{
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- if (exe_ctx.frame == NULL)
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (frame == NULL)
{
result.AppendError ("you must be stopped in a valid stack frame to view frame variables.");
result.SetStatus (eReturnStatusFailed);
@@ -383,9 +386,7 @@ public:
// Be careful about the stack frame, if any summary formatter runs code, it might clear the StackFrameList
// for the thread. So hold onto a shared pointer to the frame so it stays alive.
- StackFrameSP frame_sp = exe_ctx.frame->GetSP();
-
- VariableList *variable_list = frame_sp->GetVariableList (get_file_globals);
+ VariableList *variable_list = frame->GetVariableList (get_file_globals);
VariableSP var_sp;
ValueObjectSP valobj_sp;
@@ -458,7 +459,7 @@ public:
var_sp = regex_var_list.GetVariableAtIndex (regex_idx);
if (var_sp)
{
- valobj_sp = frame_sp->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic);
+ valobj_sp = frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic);
if (valobj_sp)
{
if (m_option_variable.format != eFormatDefault)
@@ -499,11 +500,11 @@ public:
Error error;
uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember;
lldb::VariableSP var_sp;
- valobj_sp = frame_sp->GetValueForVariableExpressionPath (name_cstr,
- m_varobj_options.use_dynamic,
- expr_path_options,
- var_sp,
- error);
+ valobj_sp = frame->GetValueForVariableExpressionPath (name_cstr,
+ m_varobj_options.use_dynamic,
+ expr_path_options,
+ var_sp,
+ error);
if (valobj_sp)
{
if (m_option_variable.format != eFormatDefault)
@@ -533,8 +534,7 @@ public:
size = valobj_sp->GetByteSize();
}
uint32_t watch_type = m_option_watchpoint.watch_type;
- WatchpointLocation *wp_loc =
- exe_ctx.target->CreateWatchpointLocation(addr, size, watch_type).get();
+ WatchpointLocation *wp_loc = exe_ctx.GetTargetRef().CreateWatchpointLocation(addr, size, watch_type).get();
if (wp_loc)
{
if (var_sp && var_sp->GetDeclaration().GetFile())
@@ -613,8 +613,8 @@ public:
// Use the variable object code to make sure we are
// using the same APIs as the the public API will be
// using...
- valobj_sp = frame_sp->GetValueObjectForFrameVariable (var_sp,
- m_varobj_options.use_dynamic);
+ valobj_sp = frame->GetValueObjectForFrameVariable (var_sp,
+ m_varobj_options.use_dynamic);
if (valobj_sp)
{
if (m_option_variable.format != eFormatDefault)
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index f6a1846013d..9629c8410b6 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -351,7 +351,8 @@ public:
CommandReturnObject &result)
{
ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
- if (exe_ctx.target == NULL)
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target == NULL)
{
result.AppendError("need at least a target to read memory");
result.SetStatus(eReturnStatusFailed);
@@ -440,9 +441,10 @@ public:
}
ConstString lookup_type_name(type_str.c_str());
- if (exe_ctx.frame)
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (frame)
{
- sc = exe_ctx.frame->GetSymbolContext (eSymbolContextModule);
+ sc = frame->GetSymbolContext (eSymbolContextModule);
if (sc.module_sp)
{
sc.module_sp->FindTypes (sc,
@@ -454,11 +456,11 @@ public:
}
if (type_list.GetSize() == 0)
{
- exe_ctx.target->GetImages().FindTypes (sc,
- lookup_type_name,
- append,
- 1,
- type_list);
+ target->GetImages().FindTypes (sc,
+ lookup_type_name,
+ append,
+ 1,
+ type_list);
}
if (type_list.GetSize() == 0)
@@ -502,7 +504,7 @@ public:
}
else
{
- error = m_memory_options.FinalizeSettings (exe_ctx.target, m_format_options);
+ error = m_memory_options.FinalizeSettings (target, m_format_options);
}
// Look for invalid combinations of settings
@@ -562,7 +564,7 @@ public:
{
data_sp.reset (new DataBufferHeap (total_byte_size, '\0'));
Address address(NULL, addr);
- bytes_read = exe_ctx.target->ReadMemory(address, false, data_sp->GetBytes (), data_sp->GetByteSize(), error);
+ bytes_read = target->ReadMemory(address, false, data_sp->GetBytes (), data_sp->GetByteSize(), error);
if (bytes_read == 0)
{
result.AppendWarningWithFormat("Read from 0x%llx failed.\n", addr);
@@ -677,8 +679,8 @@ public:
result.SetStatus(eReturnStatusSuccessFinishResult);
DataExtractor data (data_sp,
- exe_ctx.target->GetArchitecture().GetByteOrder(),
- exe_ctx.target->GetArchitecture().GetAddressByteSize());
+ target->GetArchitecture().GetByteOrder(),
+ target->GetArchitecture().GetAddressByteSize());
assert (output_stream);
@@ -870,7 +872,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
result.AppendError("need a process to read memory");
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index ed6c7f9a10e..e868f27c32d 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -373,7 +373,7 @@ public:
{
Error error;
const uint32_t argc = args.GetArgumentCount();
- Target *target = m_interpreter.GetExecutionContext().target;
+ Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
if (target)
{
Module *exe_module = target->GetExecutableModulePointer();
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 314598471c1..980f9d21e94 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -174,7 +174,7 @@ public:
exe_module->GetFileSpec().GetPath(filename, sizeof(filename));
StateType state = eStateInvalid;
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process)
{
state = process->GetState();
@@ -566,7 +566,7 @@ public:
// and the target actually stopping. So even if the interpreter is set to be asynchronous, we wait for the stop
// ourselves here.
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
StateType state = eStateInvalid;
if (process)
{
@@ -828,7 +828,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
bool synchronous_execution = m_interpreter.GetSynchronous ();
if (process == NULL)
@@ -915,7 +915,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
result.AppendError ("must have a valid process in order to detach");
@@ -1025,7 +1025,7 @@ public:
TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget());
Error error;
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process)
{
if (process->IsAlive())
@@ -1139,7 +1139,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
result.AppendError ("must have a valid process in order to load a shared library");
@@ -1198,7 +1198,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
result.AppendError ("must have a valid process in order to load a shared library");
@@ -1275,7 +1275,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
result.AppendError ("no process to signal");
@@ -1350,7 +1350,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
result.AppendError ("no process to halt");
@@ -1412,7 +1412,7 @@ public:
Execute (Args& command,
CommandReturnObject &result)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
result.AppendError ("no process to kill");
@@ -1476,18 +1476,19 @@ public:
Stream &strm = result.GetOutputStream();
result.SetStatus (eReturnStatusSuccessFinishNoResult);
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- if (exe_ctx.process)
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process)
{
const bool only_threads_with_stop_reason = true;
const uint32_t start_frame = 0;
const uint32_t num_frames = 1;
const uint32_t num_frames_with_source = 1;
- exe_ctx.process->GetStatus(strm);
- exe_ctx.process->GetThreadStatus (strm,
- only_threads_with_stop_reason,
- start_frame,
- num_frames,
- num_frames_with_source);
+ process->GetStatus(strm);
+ process->GetThreadStatus (strm,
+ only_threads_with_stop_reason,
+ start_frame,
+ num_frames,
+ num_frames_with_source);
}
else
diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp
index 730c74eed4d..73c9c8b8b9b 100644
--- a/lldb/source/Commands/CommandObjectRegister.cpp
+++ b/lldb/source/Commands/CommandObjectRegister.cpp
@@ -99,7 +99,7 @@ public:
if (reg_addr != LLDB_INVALID_ADDRESS)
{
Address so_reg_addr;
- if (exe_ctx.target->GetSectionLoadList().ResolveLoadAddress(reg_addr, so_reg_addr))
+ if (exe_ctx.GetTargetRef().GetSectionLoadList().ResolveLoadAddress(reg_addr, so_reg_addr))
{
strm.PutCString (" ");
so_reg_addr.Dump(&strm, exe_ctx.GetBestExecutionContextScope(), Address::DumpStyleResolvedDescription);
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index aba27c14437..dae2e7b37c0 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -280,11 +280,9 @@ public:
}
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- Target *target = NULL;
+ Target *target = exe_ctx.GetTargetPtr();
- if (exe_ctx.target)
- target = exe_ctx.target;
- else
+ if (target == NULL)
target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
@@ -427,7 +425,7 @@ public:
{
const bool show_inlines = true;
m_breakpoint_locations.Reset (start_file, 0, show_inlines);
- SearchFilter target_search_filter (exe_ctx.target->GetSP());
+ SearchFilter target_search_filter (exe_ctx.GetTargetSP());
target_search_filter.Search (m_breakpoint_locations);
}
else
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 8347d00aa6c..995495433be 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -649,8 +649,8 @@ public:
Execute (Args& args, CommandReturnObject &result)
{
ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
-
- if (exe_ctx.target)
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target)
{
const size_t argc = args.GetArgumentCount();
if (argc > 0)
@@ -675,21 +675,21 @@ public:
return false;
}
use_var_name = true;
- matches = exe_ctx.target->GetImages().FindGlobalVariables (regex,
- true,
- UINT32_MAX,
- variable_list);
+ matches = target->GetImages().FindGlobalVariables (regex,
+ true,
+ UINT32_MAX,
+ variable_list);
}
else
{
Error error (Variable::GetValuesForVariableExpressionPath (arg,
exe_ctx.GetBestExecutionContextScope(),
GetVariableCallback,
- exe_ctx.target,
+ target,
variable_list,
valobj_list));
-// matches = exe_ctx.target->GetImages().FindGlobalVariables (ConstString(arg),
+// matches = target->GetImages().FindGlobalVariables (ConstString(arg),
// true,
// UINT32_MAX,
// variable_list);
@@ -1170,7 +1170,7 @@ DumpCompileUnitLineTable
LineTable *line_table = sc.comp_unit->GetLineTable();
if (line_table)
line_table->GetDescription (&strm,
- interpreter.GetExecutionContext().target,
+ interpreter.GetExecutionContext().GetTargetPtr(),
lldb::eDescriptionLevelBrief);
else
strm << "No line table";
@@ -1248,7 +1248,7 @@ DumpModuleSymtab (CommandInterpreter &interpreter, Stream &strm, Module *module,
{
Symtab *symtab = objfile->GetSymtab();
if (symtab)
- symtab->Dump(&strm, interpreter.GetExecutionContext().target, sort_order);
+ symtab->Dump(&strm, interpreter.GetExecutionContext().GetTargetPtr(), sort_order);
}
}
}
@@ -1270,7 +1270,7 @@ DumpModuleSections (CommandInterpreter &interpreter, Stream &strm, Module *modul
strm << '(' << module->GetObjectName() << ')';
strm.Printf ("' (%s):\n", module->GetArchitecture().GetArchitectureName());
strm.IndentMore();
- section_list->Dump(&strm, interpreter.GetExecutionContext().target, true, UINT32_MAX);
+ section_list->Dump(&strm, interpreter.GetExecutionContext().GetTargetPtr(), true, UINT32_MAX);
strm.IndentLess();
}
}
@@ -1309,7 +1309,7 @@ LookupAddressInModule
lldb::addr_t addr = raw_addr - offset;
Address so_addr;
SymbolContext sc;
- Target *target = interpreter.GetExecutionContext().target;
+ Target *target = interpreter.GetExecutionContext().GetTargetPtr();
if (target && !target->GetSectionLoadList().IsEmpty())
{
if (!target->GetSectionLoadList().ResolveLoadAddress (addr, so_addr))
@@ -1394,7 +1394,7 @@ LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *mod
{
Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]);
strm.Indent ();
- symbol->Dump (&strm, interpreter.GetExecutionContext().target, i);
+ symbol->Dump (&strm, interpreter.GetExecutionContext().GetTargetPtr(), i);
}
strm.IndentLess ();
return num_matches;
@@ -2208,7 +2208,7 @@ public:
result.GetOutputStream(),
target->GetImages().GetModulePointerAtIndex(i),
file_spec,
- exe_ctx.process != NULL && exe_ctx.process->IsAlive()))
+ exe_ctx.GetProcessPtr() && exe_ctx.GetProcessRef().IsAlive()))
num_dumped++;
}
if (num_dumped == 0)
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 292b963ab2a..68de8724eb6 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -163,13 +163,14 @@ public:
if (command.GetArgumentCount() == 0)
{
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- if (exe_ctx.thread)
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (thread)
{
// Thread::GetStatus() returns the number of frames shown.
- if (exe_ctx.thread->GetStatus (strm,
- m_options.m_start,
- m_options.m_count,
- num_frames_with_source))
+ if (thread->GetStatus (strm,
+ m_options.m_start,
+ m_options.m_count,
+ num_frames_with_source))
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
@@ -182,7 +183,7 @@ public:
}
else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
uint32_t num_threads = process->GetThreadList().GetSize();
for (uint32_t i = 0; i < num_threads; i++)
{
@@ -205,7 +206,7 @@ public:
else
{
uint32_t num_args = command.GetArgumentCount();
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
std::vector<ThreadSP> thread_sps;
for (uint32_t i = 0; i < num_args; i++)
@@ -398,7 +399,7 @@ public:
CommandReturnObject &result
)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
bool synchronous_execution = m_interpreter.GetSynchronous();
if (process == NULL)
@@ -639,7 +640,7 @@ public:
return false;
}
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
result.AppendError ("no process exists. Cannot continue");
@@ -903,7 +904,7 @@ public:
return false;
}
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
result.AppendError ("need a valid process to step");
@@ -1125,7 +1126,7 @@ public:
CommandReturnObject &result
)
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
result.AppendError ("no process");
@@ -1198,18 +1199,19 @@ public:
Stream &strm = result.GetOutputStream();
result.SetStatus (eReturnStatusSuccessFinishNoResult);
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
- if (exe_ctx.process)
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process)
{
const bool only_threads_with_stop_reason = false;
const uint32_t start_frame = 0;
const uint32_t num_frames = 0;
const uint32_t num_frames_with_source = 0;
- exe_ctx.process->GetStatus(strm);
- exe_ctx.process->GetThreadStatus (strm,
- only_threads_with_stop_reason,
- start_frame,
- num_frames,
- num_frames_with_source);
+ process->GetStatus(strm);
+ process->GetThreadStatus (strm,
+ only_threads_with_stop_reason,
+ start_frame,
+ num_frames,
+ num_frames_with_source);
}
else
{
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp
index 200ef4cf7c0..ffb90c9b664 100644
--- a/lldb/source/Core/Address.cpp
+++ b/lldb/source/Core/Address.cpp
@@ -108,9 +108,10 @@ ReadAddress (ExecutionContextScope *exe_scope, const Address &address, uint32_t
exe_scope->CalculateExecutionContext(exe_ctx);
// If we have any sections that are loaded, try and resolve using the
// section load list
- if (exe_ctx.target && !exe_ctx.target->GetSectionLoadList().IsEmpty())
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target && !target->GetSectionLoadList().IsEmpty())
{
- if (exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (deref_addr, deref_so_addr))
+ if (target->GetSectionLoadList().ResolveLoadAddress (deref_addr, deref_so_addr))
return true;
}
else
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index c101038ca89..83c226b7664 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -337,22 +337,22 @@ ExecutionContext
Debugger::GetSelectedExecutionContext ()
{
ExecutionContext exe_ctx;
- exe_ctx.Clear();
-
- TargetSP target_sp = GetSelectedTarget();
- exe_ctx.target = target_sp.get();
+ TargetSP target_sp(GetSelectedTarget());
+ exe_ctx.SetTargetSP (target_sp);
if (target_sp)
{
- exe_ctx.process = target_sp->GetProcessSP().get();
- if (exe_ctx.process && exe_ctx.process->IsRunning() == false)
+ ProcessSP process_sp (target_sp->GetProcessSP());
+ exe_ctx.SetProcessSP (process_sp);
+ if (process_sp && process_sp->IsRunning() == false)
{
- exe_ctx.thread = exe_ctx.process->GetThreadList().GetSelectedThread().get();
- if (exe_ctx.thread)
+ ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread());
+ if (thread_sp)
{
- exe_ctx.frame = exe_ctx.thread->GetSelectedFrame().get();
- if (exe_ctx.frame == NULL)
- exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex (0).get();
+ exe_ctx.SetThreadSP (thread_sp);
+ exe_ctx.SetFrameSP (thread_sp->GetSelectedFrame());
+ if (exe_ctx.GetFramePtr() == NULL)
+ exe_ctx.SetFrameSP (thread_sp->GetStackFrameAtIndex (0));
}
}
}
@@ -1259,10 +1259,10 @@ Debugger::FormatPrompt
for (;index_lower<=index_higher;index_lower++)
{
- ValueObject* item = ExpandIndexedExpression(target,
- index_lower,
- exe_ctx->frame,
- false).get();
+ ValueObject* item = ExpandIndexedExpression (target,
+ index_lower,
+ exe_ctx->GetFramePtr(),
+ false).get();
if (!item)
{
@@ -1307,77 +1307,85 @@ Debugger::FormatPrompt
case 'p':
if (::strncmp (var_name_begin, "process.", strlen("process.")) == 0)
{
- if (exe_ctx && exe_ctx->process != NULL)
+ if (exe_ctx)
{
- var_name_begin += ::strlen ("process.");
- if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0)
- {
- s.Printf("%i", exe_ctx->process->GetID());
- var_success = true;
- }
- else if ((::strncmp (var_name_begin, "name}", strlen("name}")) == 0) ||
- (::strncmp (var_name_begin, "file.basename}", strlen("file.basename}")) == 0) ||
- (::strncmp (var_name_begin, "file.fullpath}", strlen("file.fullpath}")) == 0))
+ Process *process = exe_ctx->GetProcessPtr();
+ if (process)
{
- Module *exe_module = exe_ctx->process->GetTarget().GetExecutableModulePointer();
- if (exe_module)
+ var_name_begin += ::strlen ("process.");
+ if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0)
{
- if (var_name_begin[0] == 'n' || var_name_begin[5] == 'f')
- {
- format_file_spec.GetFilename() = exe_module->GetFileSpec().GetFilename();
- var_success = format_file_spec;
- }
- else
+ s.Printf("%i", process->GetID());
+ var_success = true;
+ }
+ else if ((::strncmp (var_name_begin, "name}", strlen("name}")) == 0) ||
+ (::strncmp (var_name_begin, "file.basename}", strlen("file.basename}")) == 0) ||
+ (::strncmp (var_name_begin, "file.fullpath}", strlen("file.fullpath}")) == 0))
+ {
+ Module *exe_module = process->GetTarget().GetExecutableModulePointer();
+ if (exe_module)
{
- format_file_spec = exe_module->GetFileSpec();
- var_success = format_file_spec;
+ if (var_name_begin[0] == 'n' || var_name_begin[5] == 'f')
+ {
+ format_file_spec.GetFilename() = exe_module->GetFileSpec().GetFilename();
+ var_success = format_file_spec;
+ }
+ else
+ {
+ format_file_spec = exe_module->GetFileSpec();
+ var_success = format_file_spec;
+ }
}
}
}
- }
+ }
}
break;
case 't':
if (::strncmp (var_name_begin, "thread.", strlen("thread.")) == 0)
{
- if (exe_ctx && exe_ctx->thread)
+ if (exe_ctx)
{
- var_name_begin += ::strlen ("thread.");
- if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0)
- {
- s.Printf("0x%4.4x", exe_ctx->thread->GetID());
- var_success = true;
- }
- else if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0)
- {
- s.Printf("%u", exe_ctx->thread->GetIndexID());
- var_success = true;
- }
- else if (::strncmp (var_name_begin, "name}", strlen("name}")) == 0)
+ Thread *thread = exe_ctx->GetThreadPtr();
+ if (thread)
{
- cstr = exe_ctx->thread->GetName();
- var_success = cstr && cstr[0];
- if (var_success)
- s.PutCString(cstr);
- }
- else if (::strncmp (var_name_begin, "queue}", strlen("queue}")) == 0)
- {
- cstr = exe_ctx->thread->GetQueueName();
- var_success = cstr && cstr[0];
- if (var_success)
- s.PutCString(cstr);
- }
- else if (::strncmp (var_name_begin, "stop-reason}", strlen("stop-reason}")) == 0)
- {
- StopInfoSP stop_info_sp = exe_ctx->thread->GetStopInfo ();
- if (stop_info_sp)
+ var_name_begin += ::strlen ("thread.");
+ if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0)
{
- cstr = stop_info_sp->GetDescription();
- if (cstr && cstr[0])
- {
+ s.Printf("0x%4.4x", thread->GetID());
+ var_success = true;
+ }
+ else if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0)
+ {
+ s.Printf("%u", thread->GetIndexID());
+ var_success = true;
+ }
+ else if (::strncmp (var_name_begin, "name}", strlen("name}")) == 0)
+ {
+ cstr = thread->GetName();
+ var_success = cstr && cstr[0];
+ if (var_success)
s.PutCString(cstr);
- var_success = true;
+ }
+ else if (::strncmp (var_name_begin, "queue}", strlen("queue}")) == 0)
+ {
+ cstr = thread->GetQueueName();
+ var_success = cstr && cstr[0];
+ if (var_success)
+ s.PutCString(cstr);
+ }
+ else if (::strncmp (var_name_begin, "stop-reason}", strlen("stop-reason}")) == 0)
+ {
+ StopInfoSP stop_info_sp = thread->GetStopInfo ();
+ if (stop_info_sp)
+ {
+ cstr = stop_info_sp->GetDescription();
+ if (cstr && cstr[0])
+ {
+ s.PutCString(cstr);
+ var_success = true;
+ }
}
}
}
@@ -1455,50 +1463,54 @@ Debugger::FormatPrompt
}
else if (::strncmp (var_name_begin, "frame.", strlen("frame.")) == 0)
{
- if (exe_ctx && exe_ctx->frame)
+ if (exe_ctx)
{
- var_name_begin += ::strlen ("frame.");
- if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0)
- {
- s.Printf("%u", exe_ctx->frame->GetFrameIndex());
- var_success = true;
- }
- else if (::strncmp (var_name_begin, "pc}", strlen("pc}")) == 0)
- {
- reg_kind = eRegisterKindGeneric;
- reg_num = LLDB_REGNUM_GENERIC_PC;
- var_success = true;
- }
- else if (::strncmp (var_name_begin, "sp}", strlen("sp}")) == 0)
- {
- reg_kind = eRegisterKindGeneric;
- reg_num = LLDB_REGNUM_GENERIC_SP;
- var_success = true;
- }
- else if (::strncmp (var_name_begin, "fp}", strlen("fp}")) == 0)
- {
- reg_kind = eRegisterKindGeneric;
- reg_num = LLDB_REGNUM_GENERIC_FP;
- var_success = true;
- }
- else if (::strncmp (var_name_begin, "flags}", strlen("flags}")) == 0)
+ StackFrame *frame = exe_ctx->GetFramePtr();
+ if (frame)
{
- reg_kind = eRegisterKindGeneric;
- reg_num = LLDB_REGNUM_GENERIC_FLAGS;
- var_success = true;
- }
- else if (::strncmp (var_name_begin, "reg.", strlen ("reg.")) == 0)
- {
- reg_ctx = exe_ctx->frame->GetRegisterContext().get();
- if (reg_ctx)
+ var_name_begin += ::strlen ("frame.");
+ if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0)
+ {
+ s.Printf("%u", frame->GetFrameIndex());
+ var_success = true;
+ }
+ else if (::strncmp (var_name_begin, "pc}", strlen("pc}")) == 0)
{
- var_name_begin += ::strlen ("reg.");
- if (var_name_begin < var_name_end)
+ reg_kind = eRegisterKindGeneric;
+ reg_num = LLDB_REGNUM_GENERIC_PC;
+ var_success = true;
+ }
+ else if (::strncmp (var_name_begin, "sp}", strlen("sp}")) == 0)
+ {
+ reg_kind = eRegisterKindGeneric;
+ reg_num = LLDB_REGNUM_GENERIC_SP;
+ var_success = true;
+ }
+ else if (::strncmp (var_name_begin, "fp}", strlen("fp}")) == 0)
+ {
+ reg_kind = eRegisterKindGeneric;
+ reg_num = LLDB_REGNUM_GENERIC_FP;
+ var_success = true;
+ }
+ else if (::strncmp (var_name_begin, "flags}", strlen("flags}")) == 0)
+ {
+ reg_kind = eRegisterKindGeneric;
+ reg_num = LLDB_REGNUM_GENERIC_FLAGS;
+ var_success = true;
+ }
+ else if (::strncmp (var_name_begin, "reg.", strlen ("reg.")) == 0)
+ {
+ reg_ctx = frame->GetRegisterContext().get();
+ if (reg_ctx)
{
- std::string reg_name (var_name_begin, var_name_end);
- reg_info = reg_ctx->GetRegisterInfoByName (reg_name.c_str());
- if (reg_info)
- var_success = true;
+ var_name_begin += ::strlen ("reg.");
+ if (var_name_begin < var_name_end)
+ {
+ std::string reg_name (var_name_begin, var_name_end);
+ reg_info = reg_ctx->GetRegisterInfoByName (reg_name.c_str());
+ if (reg_info)
+ var_success = true;
+ }
}
}
}
@@ -1564,10 +1576,11 @@ Debugger::FormatPrompt
}
else if (::strncmp (var_name_begin, "pc-offset}", strlen("pc-offset}")) == 0)
{
- var_success = exe_ctx->frame;
+ StackFrame *frame = exe_ctx->GetFramePtr();
+ var_success = frame != NULL;
if (var_success)
{
- format_addr = exe_ctx->frame->GetFrameCodeAddress();
+ format_addr = frame->GetFrameCodeAddress();
calculate_format_addr_function_offset = true;
}
}
@@ -1622,15 +1635,16 @@ Debugger::FormatPrompt
// If format addr is valid, then we need to print an address
if (reg_num != LLDB_INVALID_REGNUM)
{
+ StackFrame *frame = exe_ctx->GetFramePtr();
// We have a register value to display...
if (reg_num == LLDB_REGNUM_GENERIC_PC && reg_kind == eRegisterKindGeneric)
{
- format_addr = exe_ctx->frame->GetFrameCodeAddress();
+ format_addr = frame->GetFrameCodeAddress();
}
else
{
if (reg_ctx == NULL)
- reg_ctx = exe_ctx->frame->GetRegisterContext().get();
+ reg_ctx = frame->GetRegisterContext().get();
if (reg_ctx)
{
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index 4d8247937d1..4ebe6888e35 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -81,15 +81,16 @@ ResolveAddress (const ExecutionContext &exe_ctx,
{
// If we weren't passed in a section offset address range,
// try and resolve it to something
- if (exe_ctx.target)
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target)
{
- if (exe_ctx.target->GetSectionLoadList().IsEmpty())
+ if (target->GetSectionLoadList().IsEmpty())
{
- exe_ctx.target->GetImages().ResolveFileAddress (addr.GetOffset(), resolved_addr);
+ target->GetImages().ResolveFileAddress (addr.GetOffset(), resolved_addr);
}
else
{
- exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (addr.GetOffset(), resolved_addr);
+ target->GetSectionLoadList().ResolveLoadAddress (addr.GetOffset(), resolved_addr);
}
// We weren't able to resolve the address, just treat it as a
// raw address
@@ -174,16 +175,16 @@ Disassembler::Disassemble
true,
sc_list);
}
- else if (exe_ctx.target)
+ else if (exe_ctx.GetTargetPtr())
{
- exe_ctx.target->GetImages().FindFunctions (name,
- eFunctionNameTypeBase |
- eFunctionNameTypeFull |
- eFunctionNameTypeMethod |
- eFunctionNameTypeSelector,
- include_symbols,
- false,
- sc_list);
+ exe_ctx.GetTargetPtr()->GetImages().FindFunctions (name,
+ eFunctionNameTypeBase |
+ eFunctionNameTypeFull |
+ eFunctionNameTypeMethod |
+ eFunctionNameTypeSelector,
+ include_symbols,
+ false,
+ sc_list);
}
}
@@ -333,8 +334,10 @@ Disassembler::PrintInstructions
AddressRange sc_range;
const Address *pc_addr_ptr = NULL;
ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope();
- if (exe_ctx.frame)
- pc_addr_ptr = &exe_ctx.frame->GetFrameCodeAddress();
+ StackFrame *frame = exe_ctx.GetFramePtr();
+
+ if (frame)
+ pc_addr_ptr = &frame->GetFrameCodeAddress();
const uint32_t scope = eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol;
const bool use_inline_block_range = false;
for (size_t i=0; i<num_instructions_found; ++i)
@@ -364,7 +367,7 @@ Disassembler::PrintInstructions
if (offset != 0)
strm.EOL();
- sc.DumpStopContext(&strm, exe_ctx.process, addr, false, true, false);
+ sc.DumpStopContext(&strm, exe_ctx.GetProcessPtr(), addr, false, true, false);
strm.EOL();
if (sc.comp_unit && sc.line_entry.IsValid())
@@ -436,9 +439,10 @@ Disassembler::Disassemble
)
{
AddressRange range;
- if (exe_ctx.frame)
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (frame)
{
- SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol));
+ SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol));
if (sc.function)
{
range = sc.function->GetAddressRange();
@@ -449,7 +453,7 @@ Disassembler::Disassemble
}
else
{
- range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress();
+ range.GetBaseAddress() = frame->GetFrameCodeAddress();
}
if (range.GetBaseAddress().IsValid() && range.GetByteSize() == 0)
@@ -848,32 +852,34 @@ Disassembler::ParseInstructions
const AddressRange &range
)
{
- Target *target = exe_ctx->target;
- const addr_t byte_size = range.GetByteSize();
- if (target == NULL || byte_size == 0 || !range.GetBaseAddress().IsValid())
- return 0;
-
- DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\0');
- DataBufferSP data_sp(heap_buffer);
-
- Error error;
- const bool prefer_file_cache = true;
- const size_t bytes_read = target->ReadMemory (range.GetBaseAddress(),
- prefer_file_cache,
- heap_buffer->GetBytes(),
- heap_buffer->GetByteSize(),
- error);
-
- if (bytes_read > 0)
+ if (exe_ctx)
{
- if (bytes_read != heap_buffer->GetByteSize())
- heap_buffer->SetByteSize (bytes_read);
- DataExtractor data (data_sp,
- m_arch.GetByteOrder(),
- m_arch.GetAddressByteSize());
- return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false);
+ Target *target = exe_ctx->GetTargetPtr();
+ const addr_t byte_size = range.GetByteSize();
+ if (target == NULL || byte_size == 0 || !range.GetBaseAddress().IsValid())
+ return 0;
+
+ DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\0');
+ DataBufferSP data_sp(heap_buffer);
+
+ Error error;
+ const bool prefer_file_cache = true;
+ const size_t bytes_read = target->ReadMemory (range.GetBaseAddress(),
+ prefer_file_cache,
+ heap_buffer->GetBytes(),
+ heap_buffer->GetByteSize(),
+ error);
+
+ if (bytes_read > 0)
+ {
+ if (bytes_read != heap_buffer->GetByteSize())
+ heap_buffer->SetByteSize (bytes_read);
+ DataExtractor data (data_sp,
+ m_arch.GetByteOrder(),
+ m_arch.GetAddressByteSize());
+ return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false);
+ }
}
-
return 0;
}
@@ -887,10 +893,10 @@ Disassembler::ParseInstructions
{
m_instruction_list.Clear();
- if (num_instructions == 0 || !start.IsValid())
+ if (exe_ctx == NULL || num_instructions == 0 || !start.IsValid())
return 0;
- Target *target = exe_ctx->target;
+ Target *target = exe_ctx->GetTargetPtr();
// Calculate the max buffer size we will need in order to disassemble
const addr_t byte_size = num_instructions * m_arch.GetMaximumOpcodeByteSize();
diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp
index ee689307ac1..b0c58ac3770 100644
--- a/lldb/source/Core/FormatClasses.cpp
+++ b/lldb/source/Core/FormatClasses.cpp
@@ -84,8 +84,9 @@ StringSummaryFormat::FormatObject(lldb::ValueObjectSP object)
ExecutionContext exe_ctx;
object->GetExecutionContextScope()->CalculateExecutionContext(exe_ctx);
SymbolContext sc;
- if (exe_ctx.frame)
- sc = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything);
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (frame)
+ sc = frame->GetSymbolContext(lldb::eSymbolContextEverything);
if (m_show_members_oneliner)
{
diff --git a/lldb/source/Core/SearchFilter.cpp b/lldb/source/Core/SearchFilter.cpp
index 1d38c417dfb..835072ad3ef 100644
--- a/lldb/source/Core/SearchFilter.cpp
+++ b/lldb/source/Core/SearchFilter.cpp
@@ -583,7 +583,7 @@ SearchFilterByModuleList::GetDescription (Stream *s)
}
else
{
- s->Printf (", modules(%d) = ", num_modules);
+ s->Printf (", modules(%u) = ", num_modules);
for (uint32_t i = 0; i < num_modules; i++)
{
if (s->GetVerbose())
diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index 897ab8cb59d..c380d76fe2b 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -366,7 +366,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
}
else
{
- Process *process = exe_ctx->GetProcess();
+ Process *process = exe_ctx->GetProcessPtr();
if (process == NULL)
{
error.SetErrorString ("can't read load address (invalid process)");
@@ -386,7 +386,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
{
error.SetErrorString ("can't read file address (no execution context)");
}
- else if (exe_ctx->target == NULL)
+ else if (exe_ctx->GetTargetPtr() == NULL)
{
error.SetErrorString ("can't read file address (invalid target)");
}
@@ -419,14 +419,14 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
if (objfile)
{
Address so_addr(address, objfile->GetSectionList());
- addr_t load_address = so_addr.GetLoadAddress (exe_ctx->target);
+ addr_t load_address = so_addr.GetLoadAddress (exe_ctx->GetTargetPtr());
if (load_address != LLDB_INVALID_ADDRESS)
{
resolved = true;
address = load_address;
address_type = eAddressTypeLoad;
- data.SetByteOrder(exe_ctx->target->GetArchitecture().GetByteOrder());
- data.SetAddressByteSize(exe_ctx->target->GetArchitecture().GetAddressByteSize());
+ data.SetByteOrder(exe_ctx->GetTargetRef().GetArchitecture().GetByteOrder());
+ data.SetAddressByteSize(exe_ctx->GetTargetRef().GetArchitecture().GetAddressByteSize());
}
else
{
@@ -532,7 +532,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
// want to read the actual value by setting "prefer_file_cache"
// to false.
const bool prefer_file_cache = false;
- if (exe_ctx->target->ReadMemory(file_so_addr, prefer_file_cache, dst, byte_size, error) != byte_size)
+ if (exe_ctx->GetTargetRef().ReadMemory(file_so_addr, prefer_file_cache, dst, byte_size, error) != byte_size)
{
error.SetErrorStringWithFormat("read memory from 0x%llx failed", (uint64_t)address);
}
@@ -543,7 +543,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
// might have a valid process in the exe_ctx->target, so use
// the ExecutionContext::GetProcess accessor to ensure we
// get the process if there is one.
- Process *process = exe_ctx->GetProcess();
+ Process *process = exe_ctx->GetProcessPtr();
if (process)
{
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 1d3b749e347..71180bce4b8 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -3439,22 +3439,21 @@ ValueObject::EvaluationPoint::EvaluationPoint (ExecutionContextScope *exe_scope,
// and if so we want to cache that not the original.
if (exe_scope)
exe_scope->CalculateExecutionContext(exe_ctx);
- if (exe_ctx.target != NULL)
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target != NULL)
{
- m_target_sp = exe_ctx.target->GetSP();
-
- if (exe_ctx.process == NULL)
- m_process_sp = exe_ctx.target->GetProcessSP();
- else
- m_process_sp = exe_ctx.process->GetSP();
+ m_target_sp = target;
+ m_process_sp = exe_ctx.GetProcessSP();
+ if (!m_process_sp)
+ m_process_sp = target->GetProcessSP();
- if (m_process_sp != NULL)
+ if (m_process_sp)
{
m_mod_id = m_process_sp->GetModID();
- Thread *thread = NULL;
+ Thread *thread = exe_ctx.GetThreadPtr();
- if (exe_ctx.thread == NULL)
+ if (thread == NULL)
{
if (use_selected)
{
@@ -3463,17 +3462,17 @@ ValueObject::EvaluationPoint::EvaluationPoint (ExecutionContextScope *exe_scope,
computed_exe_scope = thread;
}
}
- else
- thread = exe_ctx.thread;
if (thread != NULL)
{
m_thread_id = thread->GetIndexID();
- if (exe_ctx.frame == NULL)
+
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (frame == NULL)
{
if (use_selected)
{
- StackFrame *frame = exe_ctx.thread->GetSelectedFrame().get();
+ frame = thread->GetSelectedFrame().get();
if (frame)
{
m_stack_id = frame->GetStackID();
@@ -3482,7 +3481,7 @@ ValueObject::EvaluationPoint::EvaluationPoint (ExecutionContextScope *exe_scope,
}
}
else
- m_stack_id = exe_ctx.frame->GetStackID();
+ m_stack_id = frame->GetStackID();
}
}
}
diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp
index 3dd360d9876..c0533627dab 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -127,11 +127,11 @@ ValueObjectDynamicValue::UpdateValue ()
}
ExecutionContext exe_ctx (GetExecutionContextScope());
-
- if (exe_ctx.target)
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target)
{
- m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder());
- m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize());
+ m_data.SetByteOrder(target->GetArchitecture().GetByteOrder());
+ m_data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
}
// First make sure our Type and/or Address haven't changed:
diff --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp
index 098c0fb6410..bd7a791b9b1 100644
--- a/lldb/source/Core/ValueObjectMemory.cpp
+++ b/lldb/source/Core/ValueObjectMemory.cpp
@@ -185,10 +185,11 @@ ValueObjectMemory::UpdateValue ()
ExecutionContext exe_ctx (GetExecutionContextScope());
- if (exe_ctx.target)
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target)
{
- m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder());
- m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize());
+ m_data.SetByteOrder(target->GetArchitecture().GetByteOrder());
+ m_data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
}
Value old_value(m_value);
@@ -220,9 +221,9 @@ ValueObjectMemory::UpdateValue ()
// Make sure this type has a value before we try and read it
// If we have a file address, convert it to a load address if we can.
- if (value_type == Value::eValueTypeFileAddress && exe_ctx.process)
+ if (value_type == Value::eValueTypeFileAddress && exe_ctx.GetProcessPtr())
{
- lldb::addr_t load_addr = m_address.GetLoadAddress(exe_ctx.target);
+ lldb::addr_t load_addr = m_address.GetLoadAddress(target);
if (load_addr != LLDB_INVALID_ADDRESS)
{
m_value.SetValueType(Value::eValueTypeLoadAddress);
diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp
index 5717406ba20..bc5dd261278 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -126,10 +126,11 @@ ValueObjectVariable::UpdateValue ()
lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS;
ExecutionContext exe_ctx (GetExecutionContextScope());
- if (exe_ctx.target)
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target)
{
- m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder());
- m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize());
+ m_data.SetByteOrder(target->GetArchitecture().GetByteOrder());
+ m_data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
}
if (expr.IsLocationList())
@@ -137,7 +138,7 @@ ValueObjectVariable::UpdateValue ()
SymbolContext sc;
variable->CalculateSymbolContext (&sc);
if (sc.function)
- loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.target);
+ loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (target);
}
Value old_value(m_value);
if (expr.Evaluate (&exe_ctx, GetClangAST(), NULL, NULL, NULL, loclist_base_load_addr, NULL, m_value, &m_error))
@@ -187,7 +188,8 @@ ValueObjectVariable::UpdateValue ()
// Make sure this type has a value before we try and read it
// If we have a file address, convert it to a load address if we can.
- if (value_type == Value::eValueTypeFileAddress && exe_ctx.process && exe_ctx.process->IsAlive())
+ Process *process = exe_ctx.GetProcessPtr();
+ if (value_type == Value::eValueTypeFileAddress && process && process->IsAlive())
{
lldb::addr_t file_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
if (file_addr != LLDB_INVALID_ADDRESS)
@@ -200,7 +202,7 @@ ValueObjectVariable::UpdateValue ()
if (objfile)
{
Address so_addr(file_addr, objfile->GetSectionList());
- lldb::addr_t load_addr = so_addr.GetLoadAddress (exe_ctx.target);
+ lldb::addr_t load_addr = so_addr.GetLoadAddress (target);
if (load_addr != LLDB_INVALID_ADDRESS)
{
m_value.SetValueType(Value::eValueTypeLoadAddress);
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 763546b589f..42c6f7a9d92 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -69,27 +69,30 @@ ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx)
{
EnableParserVars();
m_parser_vars->m_exe_ctx = &exe_ctx;
-
- if (exe_ctx.frame)
- m_parser_vars->m_sym_ctx = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything);
- else if (exe_ctx.thread)
- m_parser_vars->m_sym_ctx = exe_ctx.thread->GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything);
- else if (exe_ctx.process)
+
+ Target *target = exe_ctx.GetTargetPtr();
+ if (exe_ctx.GetFramePtr())
+ m_parser_vars->m_sym_ctx = exe_ctx.GetFramePtr()->GetSymbolContext(lldb::eSymbolContextEverything);
+ else if (exe_ctx.GetThreadPtr())
+ m_parser_vars->m_sym_ctx = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything);
+ else if (exe_ctx.GetProcessPtr())
{
m_parser_vars->m_sym_ctx.Clear();
- m_parser_vars->m_sym_ctx.target_sp = exe_ctx.target;
+ m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
}
- else if (exe_ctx.target)
+ else if (target)
{
m_parser_vars->m_sym_ctx.Clear();
- m_parser_vars->m_sym_ctx.target_sp = exe_ctx.target;
+ m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
}
- if (exe_ctx.target)
- m_parser_vars->m_persistent_vars = &exe_ctx.target->GetPersistentVariables();
+ if (target)
+ {
+ m_parser_vars->m_persistent_vars = &target->GetPersistentVariables();
- if (exe_ctx.target && !exe_ctx.target->GetScratchClangASTContext())
- return false;
+ if (!target->GetScratchClangASTContext())
+ return false;
+ }
m_parser_vars->m_target_info = GetTargetInfo();
@@ -137,16 +140,23 @@ ClangExpressionDeclMap::GetTargetInfo()
TargetInfo ret;
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
-
- if (exe_ctx->process)
- {
- ret.byte_order = exe_ctx->process->GetByteOrder();
- ret.address_byte_size = exe_ctx->process->GetAddressByteSize();
- }
- else if (exe_ctx->target)
+ if (exe_ctx)
{
- ret.byte_order = exe_ctx->target->GetArchitecture().GetByteOrder();
- ret.address_byte_size = exe_ctx->target->GetArchitecture().GetAddressByteSize();
+ Process *process = exe_ctx->GetProcessPtr();
+ if (process)
+ {
+ ret.byte_order = process->GetByteOrder();
+ ret.address_byte_size = process->GetAddressByteSize();
+ }
+ else
+ {
+ Target *target = exe_ctx->GetTargetPtr();
+ if (target)
+ {
+ ret.byte_order = target->GetArchitecture().GetByteOrder();
+ ret.address_byte_size = target->GetArchitecture().GetAddressByteSize();
+ }
+ }
}
return ret;
@@ -174,7 +184,11 @@ ClangExpressionDeclMap::BuildIntegerVariable (const ConstString &name,
assert (m_parser_vars.get());
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
- ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext());
+ if (exe_ctx == NULL)
+ return lldb::ClangExpressionVariableSP();
+ Target *target = exe_ctx->GetTargetPtr();
+
+ ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
TypeFromUser user_type(ClangASTContext::CopyType(context,
type.GetASTContext(),
@@ -249,7 +263,13 @@ ClangExpressionDeclMap::BuildCastVariable (const ConstString &name,
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
- ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext());
+ if (exe_ctx == NULL)
+ return lldb::ClangExpressionVariableSP();
+ Target *target = exe_ctx->GetTargetPtr();
+ if (target == NULL)
+ return lldb::ClangExpressionVariableSP();
+
+ ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl));
@@ -266,12 +286,16 @@ ClangExpressionDeclMap::BuildCastVariable (const ConstString &name,
TypeFromUser var_type = var_sp->GetTypeFromUser();
- VariableSP var = FindVariableInScope (*exe_ctx->frame, var_sp->GetName(), &var_type);
+ StackFrame *frame = exe_ctx->GetFramePtr();
+ if (frame == NULL)
+ return lldb::ClangExpressionVariableSP();
+
+ VariableSP var = FindVariableInScope (*frame, var_sp->GetName(), &var_type);
if (!var)
return lldb::ClangExpressionVariableSP(); // but we should handle this; it may be a persistent variable
- ValueObjectSP var_valobj = exe_ctx->frame->GetValueObjectForFrameVariable(var, lldb::eNoDynamicValues);
+ ValueObjectSP var_valobj = frame->GetValueObjectForFrameVariable(var, lldb::eNoDynamicValues);
if (!var_valobj)
return lldb::ClangExpressionVariableSP();
@@ -377,8 +401,13 @@ ClangExpressionDeclMap::AddPersistentVariable
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
-
- ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext());
+ if (exe_ctx == NULL)
+ return false;
+ Target *target = exe_ctx->GetTargetPtr();
+ if (target == NULL)
+ return false;
+
+ ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
TypeFromUser user_type(ClangASTContext::CopyType(context,
parser_type.GetASTContext(),
@@ -612,9 +641,12 @@ ClangExpressionDeclMap::GetFunctionAddress
assert (m_parser_vars.get());
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
+ ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
+ if (exe_ctx == NULL)
+ return false;
+ Target *target = exe_ctx->GetTargetPtr();
// Back out in all cases where we're not fully initialized
- if (m_parser_vars->m_exe_ctx->target == NULL)
+ if (target == NULL)
return false;
if (!m_parser_vars->m_sym_ctx.target_sp)
return false;
@@ -665,7 +697,7 @@ ClangExpressionDeclMap::GetFunctionAddress
if (!func_so_addr || !func_so_addr->IsValid())
return false;
- func_addr = func_so_addr->GetCallableLoadAddress (m_parser_vars->m_exe_ctx->target);
+ func_addr = func_so_addr->GetCallableLoadAddress (target);
return true;
}
@@ -737,10 +769,10 @@ ClangExpressionDeclMap::GetSymbolAddress (const ConstString &name)
assert (m_parser_vars.get());
if (!m_parser_vars->m_exe_ctx ||
- !m_parser_vars->m_exe_ctx->target)
+ !m_parser_vars->m_exe_ctx->GetTargetPtr())
return false;
- return GetSymbolAddress(*m_parser_vars->m_exe_ctx->target, name);
+ return GetSymbolAddress(m_parser_vars->m_exe_ctx->GetTargetRef(), name);
}
// Interface for IRInterpreter
@@ -754,9 +786,10 @@ ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value,
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
+ Process *process = exe_ctx->GetProcessPtr();
if (value.GetContextType() == Value::eContextTypeRegisterInfo)
{
- if (!exe_ctx->process)
+ if (!process)
return false;
RegisterContext *reg_ctx = exe_ctx->GetRegisterContext();
@@ -768,7 +801,7 @@ ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value,
lldb_private::RegisterValue reg_value;
Error err;
- if (!reg_value.SetFromMemoryData (reg_info, data, length, exe_ctx->process->GetByteOrder(), err))
+ if (!reg_value.SetFromMemoryData (reg_info, data, length, process->GetByteOrder(), err))
return false;
return reg_ctx->WriteRegister(reg_info, reg_value);
@@ -781,28 +814,29 @@ ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value,
return false;
case Value::eValueTypeFileAddress:
{
- if (!exe_ctx->process)
+ if (!process)
return false;
+ Target *target = exe_ctx->GetTargetPtr();
Address file_addr;
- if (!exe_ctx->target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr))
+ if (!target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr))
return false;
- lldb::addr_t load_addr = file_addr.GetLoadAddress(exe_ctx->target);
+ lldb::addr_t load_addr = file_addr.GetLoadAddress(target);
Error err;
- exe_ctx->process->WriteMemory(load_addr, data, length, err);
+ process->WriteMemory(load_addr, data, length, err);
return err.Success();
}
case Value::eValueTypeLoadAddress:
{
- if (!exe_ctx->process)
+ if (!process)
return false;
Error err;
- exe_ctx->process->WriteMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
+ process->WriteMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
return err.Success();
}
@@ -823,10 +857,12 @@ ClangExpressionDeclMap::ReadTarget (uint8_t *data,
assert (m_parser_vars.get());
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
-
+
+ Process *process = exe_ctx->GetProcessPtr();
+
if (value.GetContextType() == Value::eContextTypeRegisterInfo)
{
- if (!exe_ctx->process)
+ if (!process)
return false;
RegisterContext *reg_ctx = exe_ctx->GetRegisterContext();
@@ -841,7 +877,7 @@ ClangExpressionDeclMap::ReadTarget (uint8_t *data,
if (!reg_ctx->ReadRegister(reg_info, reg_value))
return false;
- return reg_value.GetAsMemoryData(reg_info, data, length, exe_ctx->process->GetByteOrder(), err);
+ return reg_value.GetAsMemoryData(reg_info, data, length, process->GetByteOrder(), err);
}
else
{
@@ -851,26 +887,27 @@ ClangExpressionDeclMap::ReadTarget (uint8_t *data,
return false;
case Value::eValueTypeFileAddress:
{
- if (!exe_ctx->target)
+ Target *target = exe_ctx->GetTargetPtr();
+ if (target == NULL)
return false;
Address file_addr;
- if (!exe_ctx->target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr))
+ if (!target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr))
return false;
Error err;
- exe_ctx->target->ReadMemory(file_addr, true, data, length, err);
+ target->ReadMemory(file_addr, true, data, length, err);
return err.Success();
}
case Value::eValueTypeLoadAddress:
{
- if (!exe_ctx->process)
+ if (!process)
return false;
Error err;
- exe_ctx->process->ReadMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
+ process->ReadMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
return err.Success();
}
@@ -898,22 +935,25 @@ ClangExpressionDeclMap::LookupDecl (clang::NamedDecl *decl)
const ConstString &name(expr_var_sp->GetName());
TypeFromUser type(expr_var_sp->GetTypeFromUser());
- if (m_parser_vars->m_exe_ctx->frame)
+ StackFrame *frame = m_parser_vars->m_exe_ctx->GetFramePtr();
+ if (frame)
{
- VariableSP var(FindVariableInScope (*exe_ctx.frame, name, &type));
+ VariableSP var(FindVariableInScope (*frame, name, &type));
if (var)
return *GetVariableValue(exe_ctx, var, NULL);
}
- if (m_parser_vars->m_exe_ctx->target)
+ Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr();
+
+ if (target)
{
- VariableSP global(FindGlobalVariable (*exe_ctx.target, name.GetCString(), &type));
+ VariableSP global(FindGlobalVariable (*target, name.GetCString(), &type));
if (global)
return *GetVariableValue(exe_ctx, global, NULL);
- lldb::addr_t location_load_addr = GetSymbolAddress(*exe_ctx.target, name);
+ lldb::addr_t location_load_addr = GetSymbolAddress(*target, name);
if (location_load_addr != LLDB_INVALID_ADDRESS)
{
@@ -962,7 +1002,7 @@ ClangExpressionDeclMap::Materialize
{
EnableMaterialVars();
- m_material_vars->m_process = exe_ctx.process;
+ m_material_vars->m_process = exe_ctx.GetProcessPtr();
bool result = DoMaterialize(false /* dematerialize */,
exe_ctx,
@@ -989,7 +1029,11 @@ ClangExpressionDeclMap::GetObjectPointer
{
assert (m_struct_vars.get());
- if (!exe_ctx.frame || !exe_ctx.target || !exe_ctx.process)
+ Target *target = exe_ctx.GetTargetPtr();
+ Process *process = exe_ctx.GetProcessPtr();
+ StackFrame *frame = exe_ctx.GetFramePtr();
+
+ if (frame == NULL || process == NULL || target == NULL)
{
err.SetErrorString("Couldn't load 'this' because the context is incomplete");
return false;
@@ -1001,7 +1045,7 @@ ClangExpressionDeclMap::GetObjectPointer
return false;
}
- VariableSP object_ptr_var = FindVariableInScope (*exe_ctx.frame,
+ VariableSP object_ptr_var = FindVariableInScope (*frame,
object_name,
(suppress_type_check ? NULL : &m_struct_vars->m_object_pointer_type));
@@ -1029,7 +1073,7 @@ ClangExpressionDeclMap::GetObjectPointer
case Value::eValueTypeLoadAddress:
{
lldb::addr_t value_addr = location_value->GetScalar().ULongLong();
- uint32_t address_byte_size = exe_ctx.target->GetArchitecture().GetAddressByteSize();
+ uint32_t address_byte_size = target->GetArchitecture().GetAddressByteSize();
if (ClangASTType::GetClangTypeBitWidth(m_struct_vars->m_object_pointer_type.GetASTContext(),
m_struct_vars->m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8)
@@ -1039,7 +1083,7 @@ ClangExpressionDeclMap::GetObjectPointer
}
Error read_error;
- object_ptr = exe_ctx.process->ReadPointerFromMemory (value_addr, read_error);
+ object_ptr = process->ReadPointerFromMemory (value_addr, read_error);
if (read_error.Fail() || object_ptr == LLDB_INVALID_ADDRESS)
{
err.SetErrorStringWithFormat("Coldn't read '%s' from the target: %s", object_name.GetCString(), read_error.AsCString());
@@ -1133,14 +1177,16 @@ ClangExpressionDeclMap::DumpMaterializedStruct
err.SetErrorString("Structure hasn't been laid out yet");
return false;
}
-
- if (!exe_ctx.process)
+ Process *process = exe_ctx.GetProcessPtr();
+
+ if (!process)
{
err.SetErrorString("Couldn't find the process");
return false;
}
- if (!exe_ctx.target)
+ Target *target = exe_ctx.GetTargetPtr();
+ if (!target)
{
err.SetErrorString("Couldn't find the target");
return false;
@@ -1155,7 +1201,7 @@ ClangExpressionDeclMap::DumpMaterializedStruct
lldb::DataBufferSP data_sp(new DataBufferHeap(m_struct_vars->m_struct_size, 0));
Error error;
- if (exe_ctx.process->ReadMemory (m_material_vars->m_materialized_location,
+ if (process->ReadMemory (m_material_vars->m_materialized_location,
data_sp->GetBytes(),
data_sp->GetByteSize(), error) != data_sp->GetByteSize())
{
@@ -1163,7 +1209,7 @@ ClangExpressionDeclMap::DumpMaterializedStruct
return false;
}
- DataExtractor extractor(data_sp, exe_ctx.process->GetByteOrder(), exe_ctx.target->GetArchitecture().GetAddressByteSize());
+ DataExtractor extractor(data_sp, process->GetByteOrder(), target->GetArchitecture().GetAddressByteSize());
for (size_t member_idx = 0, num_members = m_struct_members.GetSize();
member_idx < num_members;
@@ -1219,13 +1265,15 @@ ClangExpressionDeclMap::DoMaterialize
return false;
}
- if (!exe_ctx.frame)
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (!frame)
{
err.SetErrorString("Received null execution frame");
return false;
}
+ Target *target = exe_ctx.GetTargetPtr();
- ClangPersistentVariables &persistent_vars = exe_ctx.target->GetPersistentVariables();
+ ClangPersistentVariables &persistent_vars = target->GetPersistentVariables();
if (!m_struct_vars->m_struct_size)
{
@@ -1237,20 +1285,21 @@ ClangExpressionDeclMap::DoMaterialize
return true;
}
- const SymbolContext &sym_ctx(exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything));
+ const SymbolContext &sym_ctx(frame->GetSymbolContext(lldb::eSymbolContextEverything));
if (!dematerialize)
{
+ Process *process = exe_ctx.GetProcessPtr();
if (m_material_vars->m_materialized_location)
{
- exe_ctx.process->DeallocateMemory(m_material_vars->m_materialized_location);
+ process->DeallocateMemory(m_material_vars->m_materialized_location);
m_material_vars->m_materialized_location = 0;
}
if (log)
log->PutCString("Allocating memory for materialized argument struct");
- lldb::addr_t mem = exe_ctx.process->AllocateMemory(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size,
+ lldb::addr_t mem = process->AllocateMemory(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size,
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
err);
@@ -1369,7 +1418,8 @@ ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
return false;
Error error;
-
+ Process *process = exe_ctx.GetProcessPtr();
+
lldb::addr_t mem; // The address of a spare memory area used to hold the persistent variable.
if (dematerialize)
@@ -1383,7 +1433,7 @@ ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
// Get the location of the target out of the struct.
Error read_error;
- mem = exe_ctx.process->ReadPointerFromMemory (addr, read_error);
+ mem = process->ReadPointerFromMemory (addr, read_error);
if (mem == LLDB_INVALID_ADDRESS)
{
@@ -1429,7 +1479,7 @@ ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
// Read the contents of the spare memory area
var_sp->ValueUpdated ();
- if (exe_ctx.process->ReadMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size)
+ if (process->ReadMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size)
{
err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString());
return false;
@@ -1461,7 +1511,7 @@ ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
}
else
{
- Error deallocate_error = exe_ctx.process->DeallocateMemory(mem);
+ Error deallocate_error = process->DeallocateMemory(mem);
if (!err.Success())
{
@@ -1488,7 +1538,7 @@ ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
Error allocate_error;
- mem = exe_ctx.process->AllocateMemory(pvar_byte_size,
+ mem = process->AllocateMemory(pvar_byte_size,
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
allocate_error);
@@ -1518,7 +1568,7 @@ ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
// Write the contents of the variable to the area.
- if (exe_ctx.process->WriteMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size)
+ if (process->WriteMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size)
{
err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString());
return false;
@@ -1530,9 +1580,9 @@ ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
{
// Now write the location of the area into the struct.
Error write_error;
- if (!exe_ctx.process->WriteScalarToMemory (addr,
+ if (!process->WriteScalarToMemory (addr,
var_sp->m_live_sp->GetValue().GetScalar(),
- exe_ctx.process->GetAddressByteSize(),
+ process->GetAddressByteSize(),
write_error))
{
err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", var_sp->GetName().GetCString(), write_error.AsCString());
@@ -1564,8 +1614,11 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
)
{
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
- if (!exe_ctx.frame || !exe_ctx.process)
+ Target *target = exe_ctx.GetTargetPtr();
+ Process *process = exe_ctx.GetProcessPtr();
+ StackFrame *frame = exe_ctx.GetFramePtr();
+
+ if (!frame || !process || !target)
return false;
// Vital information about the value
@@ -1573,8 +1626,8 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
const ConstString &name(expr_var->GetName());
TypeFromUser type(expr_var->GetTypeFromUser());
- VariableSP var = FindVariableInScope (*exe_ctx.frame, name, &type);
- Symbol *sym = FindGlobalDataSymbol(*exe_ctx.target, name);
+ VariableSP var = FindVariableInScope (*frame, name, &type);
+ Symbol *sym = FindGlobalDataSymbol(*target, name);
std::auto_ptr<lldb_private::Value> location_value;
@@ -1588,7 +1641,7 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
{
location_value.reset(new Value);
- addr_t location_load_addr = GetSymbolAddress(*exe_ctx.target, name);
+ addr_t location_load_addr = GetSymbolAddress(*target, name);
if (location_load_addr == LLDB_INVALID_ADDRESS)
{
@@ -1654,9 +1707,9 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
{
Error write_error;
- if (!exe_ctx.process->WriteScalarToMemory (addr,
+ if (!process->WriteScalarToMemory (addr,
location_value->GetScalar(),
- exe_ctx.process->GetAddressByteSize(),
+ process->GetAddressByteSize(),
write_error))
{
err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s",
@@ -1738,7 +1791,7 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
// Deallocate the spare area and clear the variable's live data.
- Error deallocate_error = exe_ctx.process->DeallocateMemory(reg_addr.ULongLong());
+ Error deallocate_error = process->DeallocateMemory(reg_addr.ULongLong());
if (!deallocate_error.Success())
{
@@ -1757,7 +1810,7 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
Error allocate_error;
- Scalar reg_addr (exe_ctx.process->AllocateMemory (value_byte_size,
+ Scalar reg_addr (process->AllocateMemory (value_byte_size,
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
allocate_error));
@@ -1783,9 +1836,9 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
Error write_error;
- if (!exe_ctx.process->WriteScalarToMemory (addr,
+ if (!process->WriteScalarToMemory (addr,
reg_addr,
- exe_ctx.process->GetAddressByteSize(),
+ process->GetAddressByteSize(),
write_error))
{
err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s",
@@ -2088,6 +2141,8 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
// Only look for functions by name out in our symbols if the function
// doesn't start with our phony prefix of '$'
+ Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr();
+ StackFrame *frame = m_parser_vars->m_exe_ctx->GetFramePtr();
if (name_unique_cstr[0] != '$')
{
ValueObjectSP valobj;
@@ -2095,9 +2150,9 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
Error err;
bool found = false;
- if (m_parser_vars->m_exe_ctx->frame)
+ if (frame)
{
- valobj = m_parser_vars->m_exe_ctx->frame->GetValueForVariableExpressionPath(name_unique_cstr,
+ valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr,
eNoDynamicValues,
StackFrame::eExpressionPathOptionCheckPtrVsMember,
var,
@@ -2110,11 +2165,11 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
found = true;
}
}
- else if (m_parser_vars->m_exe_ctx->target)
+ else if (target)
{
- var = FindGlobalVariable(*m_parser_vars->m_exe_ctx->target,
- name_unique_cstr,
- NULL);
+ var = FindGlobalVariable (*target,
+ name_unique_cstr,
+ NULL);
if (var)
{
@@ -2183,7 +2238,7 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
// We couldn't find a variable or function for this. Now we'll hunt for a generic
// data symbol, and -- if it is found -- treat it as a variable.
- Symbol *data_symbol = FindGlobalDataSymbol(*m_parser_vars->m_exe_ctx->target, name);
+ Symbol *data_symbol = FindGlobalDataSymbol(*target, name);
if (data_symbol)
{
@@ -2221,10 +2276,10 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
{
// Clang is looking for the type of "this"
- if (!m_parser_vars->m_exe_ctx->frame)
+ if (!frame)
return;
- VariableList *vars = m_parser_vars->m_exe_ctx->frame->GetVariableList(false);
+ VariableList *vars = frame->GetVariableList(false);
if (!vars)
return;
@@ -2232,8 +2287,8 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
if (!this_var ||
- !this_var->IsInScope(m_parser_vars->m_exe_ctx->frame) ||
- !this_var->LocationIsValidForFrame (m_parser_vars->m_exe_ctx->frame))
+ !this_var->IsInScope(frame) ||
+ !this_var->LocationIsValidForFrame (frame))
return;
Type *this_type = this_var->GetType();
@@ -2286,10 +2341,10 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
{
// Clang is looking for the type of "*self"
- if (!m_parser_vars->m_exe_ctx->frame)
+ if (!frame)
return;
- VariableList *vars = m_parser_vars->m_exe_ctx->frame->GetVariableList(false);
+ VariableList *vars = frame->GetVariableList(false);
if (!vars)
return;
@@ -2297,8 +2352,8 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
if (!self_var ||
- !self_var->IsInScope(m_parser_vars->m_exe_ctx->frame) ||
- !self_var->LocationIsValidForFrame (m_parser_vars->m_exe_ctx->frame))
+ !self_var->IsInScope(frame) ||
+ !self_var->LocationIsValidForFrame (frame))
return;
Type *self_type = self_var->GetType();
@@ -2336,10 +2391,10 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
do
{
- if (!m_parser_vars->m_exe_ctx->target)
+ if (!target)
break;
- ClangASTContext *scratch_clang_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext();
+ ClangASTContext *scratch_clang_ast_context = target->GetScratchClangASTContext();
if (!scratch_clang_ast_context)
break;
@@ -2547,11 +2602,13 @@ ClangExpressionDeclMap::GetVariableValue
lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS;
+ Target *target = exe_ctx.GetTargetPtr();
+
if (var_location_expr.IsLocationList())
{
SymbolContext var_sc;
var->CalculateSymbolContext (&var_sc);
- loclist_base_load_addr = var_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.target);
+ loclist_base_load_addr = var_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (target);
}
Error err;
@@ -2600,7 +2657,7 @@ ClangExpressionDeclMap::GetVariableValue
Address so_addr(var_location->GetScalar().ULongLong(), object_file->GetSectionList());
- lldb::addr_t load_addr = so_addr.GetLoadAddress(exe_ctx.target);
+ lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
if (load_addr != LLDB_INVALID_ADDRESS)
{
@@ -2708,7 +2765,12 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
- ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext();
+ Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr();
+
+ if (target == NULL)
+ return;
+
+ ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
TypeFromUser user_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(scratch_ast_context, true)),
scratch_ast_context);
@@ -2731,7 +2793,7 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
AddressRange &symbol_range = symbol.GetAddressRangeRef();
Address &symbol_address = symbol_range.GetBaseAddress();
- lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(m_parser_vars->m_exe_ctx->target);
+ lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target);
symbol_location->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
symbol_location->GetScalar() = symbol_load_addr;
@@ -2767,8 +2829,9 @@ bool
ClangExpressionDeclMap::ResolveUnknownTypes()
{
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
- ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext();
+ Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr();
+
+ ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
for (size_t index = 0, num_entities = m_found_entities.GetSize();
index < num_entities;
@@ -2934,7 +2997,9 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
return;
}
- lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(m_parser_vars->m_exe_ctx->target);
+ Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr();
+
+ lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(target);
fun_location->SetValueType(Value::eValueTypeLoadAddress);
fun_location->GetScalar() = load_addr;
diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp
index 3549196ed68..e674565558e 100644
--- a/lldb/source/Expression/ClangExpressionParser.cpp
+++ b/lldb/source/Expression/ClangExpressionParser.cpp
@@ -463,9 +463,9 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
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 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
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 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
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 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
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 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
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 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
}
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 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
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 @@ ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &ex
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 @@ ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &ex
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 @@ ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &ex
return ret;
}
- ArchSpec arch(exe_ctx.target->GetArchitecture());
+ ArchSpec arch(target->GetArchitecture());
Disassembler *disassembler = Disassembler::FindPlugin(arch, NULL);
@@ -760,7 +764,7 @@ ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &ex
return ret;
}
- if (!exe_ctx.process)
+ if (!process)
{
ret.SetErrorToGenericError();
ret.SetErrorString("Couldn't find the process");
@@ -768,8 +772,8 @@ ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &ex
}
DataExtractor extractor(buffer_sp,
- exe_ctx.process->GetByteOrder(),
- exe_ctx.target->GetArchitecture().GetAddressByteSize());
+ process->GetByteOrder(),
+ target->GetArchitecture().GetAddressByteSize());
if (log)
{
diff --git a/lldb/source/Expression/ClangFunction.cpp b/lldb/source/Expression/ClangFunction.cpp
index 21acb5b3318..642463d49e3 100644
--- a/lldb/source/Expression/ClangFunction.cpp
+++ b/lldb/source/Expression/ClangFunction.cpp
@@ -237,7 +237,7 @@ ClangFunction::CompileFunction (Stream &errors)
bool
ClangFunction::WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors)
{
- Process *process = exe_ctx.process;
+ Process *process = exe_ctx.GetProcessPtr();
if (!process)
return false;
@@ -266,8 +266,8 @@ ClangFunction::WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors)
if (!jit_error.Success())
return false;
- 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;
}
@@ -299,7 +299,7 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx,
using namespace clang;
ExecutionResults return_value = eExecutionSetupError;
- Process *process = exe_ctx.process;
+ Process *process = exe_ctx.GetProcessPtr();
if (process == NULL)
return return_value;
@@ -324,7 +324,7 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx,
}
// TODO: verify fun_addr needs to be a callable address
- Scalar fun_addr (function_address.GetCallableLoadAddress(exe_ctx.target));
+ Scalar fun_addr (function_address.GetCallableLoadAddress(exe_ctx.GetTargetPtr()));
int first_offset = m_member_offsets[0];
process->WriteScalarToMemory(args_addr_ref + first_offset, fun_addr, process->GetAddressByteSize(), error);
@@ -394,8 +394,8 @@ ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx,
lldb::addr_t *cmd_arg)
{
// FIXME: Use the errors Stream for better error reporting.
-
- if (exe_ctx.thread == NULL)
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (thread == NULL)
{
errors.Printf("Can't call a function without a valid thread.");
return NULL;
@@ -404,7 +404,7 @@ ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exe_ctx,
// Okay, now run the function:
Address wrapper_address (NULL, func_addr);
- ThreadPlan *new_plan = new ThreadPlanCallFunction (*exe_ctx.thread,
+ ThreadPlan *new_plan = new ThreadPlanCallFunction (*thread,
wrapper_address,
args_addr,
stop_others,
@@ -420,7 +420,7 @@ ClangFunction::FetchFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t arg
// Read the return value - it is the last field in the struct:
// FIXME: How does clang tell us there's no return value? We need to handle that case.
- Process *process = exe_ctx.process;
+ Process *process = exe_ctx.GetProcessPtr();
if (process == NULL)
return false;
@@ -446,7 +446,7 @@ ClangFunction::DeallocateFunctionResults (ExecutionContext &exe_ctx, lldb::addr_
if (pos != m_wrapper_args_addrs.end())
m_wrapper_args_addrs.erase(pos);
- exe_ctx.process->DeallocateMemory(args_addr);
+ exe_ctx.GetProcessRef().DeallocateMemory(args_addr);
}
ExecutionResults
@@ -490,16 +490,24 @@ ClangFunction::ExecuteFunction (
Stream &errors,
lldb::addr_t *this_arg)
{
- lldb::ThreadPlanSP call_plan_sp(ClangFunction::GetThreadPlanToCallFunction(exe_ctx, function_address, void_arg,
- errors, stop_others, discard_on_error,
- this_arg));
+ lldb::ThreadPlanSP call_plan_sp (ClangFunction::GetThreadPlanToCallFunction (exe_ctx,
+ function_address,
+ void_arg,
+ errors,
+ stop_others,
+ discard_on_error,
+ this_arg));
if (call_plan_sp == NULL)
return eExecutionSetupError;
call_plan_sp->SetPrivate(true);
- return exe_ctx.process->RunThreadPlan (exe_ctx, call_plan_sp, stop_others, try_all_threads, discard_on_error,
- single_thread_timeout_usec, errors);
+ return exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, call_plan_sp,
+ stop_others,
+ try_all_threads,
+ discard_on_error,
+ single_thread_timeout_usec,
+ errors);
}
ExecutionResults
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));
diff --git a/lldb/source/Expression/ClangUtilityFunction.cpp b/lldb/source/Expression/ClangUtilityFunction.cpp
index 0d11c91743b..6f31d4ce26f 100644
--- a/lldb/source/Expression/ClangUtilityFunction.cpp
+++ b/lldb/source/Expression/ClangUtilityFunction.cpp
@@ -77,7 +77,7 @@ ClangUtilityFunction::Install (Stream &error_stream,
// Set up the target and compiler
//
- Target *target = exe_ctx.target;
+ Target *target = exe_ctx.GetTargetPtr();
if (!target)
{
@@ -85,7 +85,7 @@ ClangUtilityFunction::Install (Stream &error_stream,
return false;
}
- Process *process = exe_ctx.process;
+ Process *process = exe_ctx.GetProcessPtr();
if (!process)
{
@@ -101,7 +101,7 @@ ClangUtilityFunction::Install (Stream &error_stream,
m_expr_decl_map.reset(new ClangExpressionDeclMap(keep_result_in_memory));
- m_data_allocator.reset(new ProcessDataAllocator(*exe_ctx.process));
+ m_data_allocator.reset(new ProcessDataAllocator(*process));
if (!m_expr_decl_map->WillParse(exe_ctx))
{
@@ -147,8 +147,8 @@ ClangUtilityFunction::Install (Stream &error_stream,
log->Printf("Data buffer contents:\n%s", dump_string.GetString().c_str());
}
- if (exe_ctx.process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
- m_jit_process_sp = exe_ctx.process->GetSP();
+ if (m_jit_start_addr != LLDB_INVALID_ADDRESS)
+ m_jit_process_sp = process->GetSP();
#if 0
// jingham: look here
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 037fbc1e285..9b7f93eb5e1 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -930,10 +930,14 @@ DWARFExpression::Evaluate
{
uint32_t offset = 0;
addr_t pc;
+ StackFrame *frame = NULL;
if (reg_ctx)
pc = reg_ctx->GetPC();
else
- pc = exe_ctx->frame->GetRegisterContext()->GetPC();
+ {
+ frame = exe_ctx->GetFramePtr();
+ pc = frame->GetRegisterContext()->GetPC();
+ }
if (loclist_base_load_addr != LLDB_INVALID_ADDRESS)
{
@@ -1000,8 +1004,16 @@ DWARFExpression::Evaluate
{
std::vector<Value> stack;
- if (reg_ctx == NULL && exe_ctx && exe_ctx->frame)
- reg_ctx = exe_ctx->frame->GetRegisterContext().get();
+ Process *process = NULL;
+ StackFrame *frame = NULL;
+
+ if (exe_ctx)
+ {
+ process = exe_ctx->GetProcessPtr();
+ frame = exe_ctx->GetFramePtr();
+ }
+ if (reg_ctx == NULL && frame)
+ reg_ctx = frame->GetRegisterContext().get();
if (initial_value_ptr)
stack.push_back(*initial_value_ptr);
@@ -1110,15 +1122,15 @@ DWARFExpression::Evaluate
case Value::eValueTypeLoadAddress:
if (exe_ctx)
{
- if (exe_ctx->process)
+ if (process)
{
lldb::addr_t pointer_addr = stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
uint8_t addr_bytes[sizeof(lldb::addr_t)];
- uint32_t addr_size = exe_ctx->process->GetAddressByteSize();
+ uint32_t addr_size = process->GetAddressByteSize();
Error error;
- if (exe_ctx->process->ReadMemory(pointer_addr, &addr_bytes, addr_size, error) == addr_size)
+ if (process->ReadMemory(pointer_addr, &addr_bytes, addr_size, error) == addr_size)
{
- DataExtractor addr_data(addr_bytes, sizeof(addr_bytes), exe_ctx->process->GetByteOrder(), addr_size);
+ DataExtractor addr_data(addr_bytes, sizeof(addr_bytes), process->GetByteOrder(), addr_size);
uint32_t addr_data_offset = 0;
stack.back().GetScalar() = addr_data.GetPointer(&addr_data_offset);
stack.back().ClearContext();
@@ -1202,14 +1214,14 @@ DWARFExpression::Evaluate
case Value::eValueTypeLoadAddress:
if (exe_ctx)
{
- if (exe_ctx->process)
+ if (process)
{
lldb::addr_t pointer_addr = stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
uint8_t addr_bytes[sizeof(lldb::addr_t)];
Error error;
- if (exe_ctx->process->ReadMemory(pointer_addr, &addr_bytes, size, error) == size)
+ if (process->ReadMemory(pointer_addr, &addr_bytes, size, error) == size)
{
- DataExtractor addr_data(addr_bytes, sizeof(addr_bytes), exe_ctx->process->GetByteOrder(), size);
+ DataExtractor addr_data(addr_bytes, sizeof(addr_bytes), process->GetByteOrder(), size);
uint32_t addr_data_offset = 0;
switch (size)
{
@@ -2170,25 +2182,35 @@ DWARFExpression::Evaluate
break;
case DW_OP_fbreg:
- if (exe_ctx && exe_ctx->frame)
+ if (exe_ctx)
{
- Scalar value;
- if (exe_ctx->frame->GetFrameBaseValue(value, error_ptr))
+ if (frame)
{
- int64_t fbreg_offset = opcodes.GetSLEB128(&offset);
- value += fbreg_offset;
- stack.push_back(value);
- stack.back().SetValueType (Value::eValueTypeLoadAddress);
+ Scalar value;
+ if (frame->GetFrameBaseValue(value, error_ptr))
+ {
+ int64_t fbreg_offset = opcodes.GetSLEB128(&offset);
+ value += fbreg_offset;
+ stack.push_back(value);
+ stack.back().SetValueType (Value::eValueTypeLoadAddress);
+ }
+ else
+ return false;
}
else
+ {
+ if (error_ptr)
+ error_ptr->SetErrorString ("Invalid stack frame in context for DW_OP_fbreg opcode.");
return false;
+ }
}
else
{
if (error_ptr)
- error_ptr->SetErrorString ("Invalid stack frame in context for DW_OP_fbreg opcode.");
+ error_ptr->SetErrorStringWithFormat ("NULL execution context for DW_OP_fbreg.\n");
return false;
}
+
break;
//----------------------------------------------------------------------
@@ -2474,14 +2496,14 @@ DWARFExpression::Evaluate
data.SetByteSize(byte_size);
Error error;
- if (exe_ctx->process->ReadMemory (source_addr, data.GetBytes(), byte_size, error) != byte_size)
+ if (process->ReadMemory (source_addr, data.GetBytes(), byte_size, error) != byte_size)
{
if (error_ptr)
error_ptr->SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString());
return false;
}
- if (exe_ctx->process->WriteMemory (target_addr, data.GetBytes(), byte_size, error) != byte_size)
+ if (process->WriteMemory (target_addr, data.GetBytes(), byte_size, error) != byte_size)
{
if (error_ptr)
error_ptr->SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString());
@@ -2490,7 +2512,7 @@ DWARFExpression::Evaluate
}
break;
case Value::eValueTypeHostAddress:
- if (exe_ctx->process->GetByteOrder() != lldb::endian::InlHostByteOrder())
+ if (process->GetByteOrder() != lldb::endian::InlHostByteOrder())
{
if (error_ptr)
error_ptr->SetErrorStringWithFormat ("Copy of composite types between incompatible byte orders is unimplemented");
@@ -2499,7 +2521,7 @@ DWARFExpression::Evaluate
else
{
Error error;
- if (exe_ctx->process->ReadMemory (source_addr, (uint8_t*)target_addr, byte_size, error) != byte_size)
+ if (process->ReadMemory (source_addr, (uint8_t*)target_addr, byte_size, error) != byte_size)
{
if (error_ptr)
error_ptr->SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString());
@@ -2515,7 +2537,7 @@ DWARFExpression::Evaluate
switch (target_value_type)
{
case Value::eValueTypeLoadAddress:
- if (exe_ctx->process->GetByteOrder() != lldb::endian::InlHostByteOrder())
+ if (process->GetByteOrder() != lldb::endian::InlHostByteOrder())
{
if (error_ptr)
error_ptr->SetErrorStringWithFormat ("Copy of composite types between incompatible byte orders is unimplemented");
@@ -2524,7 +2546,7 @@ DWARFExpression::Evaluate
else
{
Error error;
- if (exe_ctx->process->WriteMemory (target_addr, (uint8_t*)source_addr, byte_size, error) != byte_size)
+ if (process->WriteMemory (target_addr, (uint8_t*)source_addr, byte_size, error) != byte_size)
{
if (error_ptr)
error_ptr->SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString());
diff --git a/lldb/source/Expression/IRDynamicChecks.cpp b/lldb/source/Expression/IRDynamicChecks.cpp
index 22624eaf613..2af5e5ebedd 100644
--- a/lldb/source/Expression/IRDynamicChecks.cpp
+++ b/lldb/source/Expression/IRDynamicChecks.cpp
@@ -56,9 +56,11 @@ DynamicCheckerFunctions::Install(Stream &error_stream,
if (!m_valid_pointer_check->Install(error_stream, exe_ctx))
return false;
- if (exe_ctx.process)
+ Process *process = exe_ctx.GetProcessPtr();
+
+ if (process)
{
- ObjCLanguageRuntime *objc_language_runtime = exe_ctx.process->GetObjCLanguageRuntime();
+ ObjCLanguageRuntime *objc_language_runtime = process->GetObjCLanguageRuntime();
if (objc_language_runtime)
{
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index d2aa0ddbc13..4b4c79a5587 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1856,8 +1856,12 @@ PlatformSP
CommandInterpreter::GetPlatform (bool prefer_target_platform)
{
PlatformSP platform_sp;
- if (prefer_target_platform && m_exe_ctx.target)
- platform_sp = m_exe_ctx.target->GetPlatform();
+ if (prefer_target_platform)
+ {
+ Target *target = m_exe_ctx.GetTargetPtr();
+ if (target)
+ platform_sp = target->GetPlatform();
+ }
if (!platform_sp)
platform_sp = m_debugger.GetPlatformList().GetSelectedPlatform();
@@ -2222,31 +2226,32 @@ CommandInterpreter::UpdateExecutionContext (ExecutionContext *override_context)
if (override_context != NULL)
{
- m_exe_ctx.target = override_context->target;
- m_exe_ctx.process = override_context->process;
- m_exe_ctx.thread = override_context->thread;
- m_exe_ctx.frame = override_context->frame;
+ m_exe_ctx = *override_context;
}
else
{
TargetSP target_sp (m_debugger.GetSelectedTarget());
if (target_sp)
{
- m_exe_ctx.target = target_sp.get();
- m_exe_ctx.process = target_sp->GetProcessSP().get();
- if (m_exe_ctx.process && m_exe_ctx.process->IsAlive() && !m_exe_ctx.process->IsRunning())
+ m_exe_ctx.SetTargetSP (target_sp);
+ ProcessSP process_sp (target_sp->GetProcessSP());
+ m_exe_ctx.SetProcessSP (process_sp);
+ if (process_sp && process_sp->IsAlive() && !process_sp->IsRunning())
{
- m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetSelectedThread().get();
- if (m_exe_ctx.thread)
+ ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread().get());
+ if (thread_sp)
{
- m_exe_ctx.frame = m_exe_ctx.thread->GetSelectedFrame().get();
- if (m_exe_ctx.frame == NULL)
+ m_exe_ctx.SetThreadSP (thread_sp);
+ StackFrameSP frame_sp (thread_sp->GetSelectedFrame());
+ if (!frame_sp)
{
- m_exe_ctx.frame = m_exe_ctx.thread->GetStackFrameAtIndex (0).get();
+ frame_sp = thread_sp->GetStackFrameAtIndex (0);
// If we didn't have a selected frame select one here.
- if (m_exe_ctx.frame != NULL)
- m_exe_ctx.thread->SetSelectedFrame(m_exe_ctx.frame);
+ if (frame_sp)
+ thread_sp->SetSelectedFrame(frame_sp.get());
}
+ if (frame_sp)
+ m_exe_ctx.SetFrameSP (frame_sp);
}
}
}
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index eb1c9218492..56f9eecf70c 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -232,7 +232,7 @@ CommandObject::ExecuteWithOptions (Args& args, CommandReturnObject &result)
if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused))
{
- Process *process = m_interpreter.GetExecutionContext().process;
+ Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
// A process that is not running is considered paused.
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 4557883ecc0..e4c2b6634fa 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -138,7 +138,7 @@ OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interp
be_raw = false;
ignore_cap = false;
- Target *target = interpreter.GetExecutionContext().target;
+ Target *target = interpreter.GetExecutionContext().GetTargetPtr();
if (target != NULL)
use_dynamic = target->GetPreferDynamicValue();
else
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 6b5fe714e9e..634f76d60f6 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -314,9 +314,9 @@ ScriptInterpreterPython::EnterSession ()
run_string.Clear();
- ExecutionContext exe_ctx = m_interpreter.GetDebugger().GetSelectedExecutionContext();
+ ExecutionContext exe_ctx (m_interpreter.GetDebugger().GetSelectedExecutionContext());
- if (exe_ctx.target)
+ if (exe_ctx.GetTargetPtr())
run_string.Printf ("run_one_line (%s, 'lldb.target = lldb.debugger.GetSelectedTarget()')",
m_dictionary_name.c_str());
else
@@ -324,14 +324,14 @@ ScriptInterpreterPython::EnterSession ()
PyRun_SimpleString (run_string.GetData());
run_string.Clear();
- if (exe_ctx.process)
+ if (exe_ctx.GetProcessPtr())
run_string.Printf ("run_one_line (%s, 'lldb.process = lldb.target.GetProcess()')", m_dictionary_name.c_str());
else
run_string.Printf ("run_one_line (%s, 'lldb.process = None')", m_dictionary_name.c_str());
PyRun_SimpleString (run_string.GetData());
run_string.Clear();
- if (exe_ctx.thread)
+ if (exe_ctx.GetThreadPtr())
run_string.Printf ("run_one_line (%s, 'lldb.thread = lldb.process.GetSelectedThread ()')",
m_dictionary_name.c_str());
else
@@ -339,7 +339,7 @@ ScriptInterpreterPython::EnterSession ()
PyRun_SimpleString (run_string.GetData());
run_string.Clear();
- if (exe_ctx.frame)
+ if (exe_ctx.GetFramePtr())
run_string.Printf ("run_one_line (%s, 'lldb.frame = lldb.thread.GetSelectedFrame ()')",
m_dictionary_name.c_str());
else
@@ -1560,7 +1560,7 @@ ScriptInterpreterPython::BreakpointCallbackFunction
if (!context)
return true;
- Target *target = context->exe_ctx.target;
+ Target *target = context->exe_ctx.GetTargetPtr();
if (!target)
return true;
@@ -1575,8 +1575,7 @@ ScriptInterpreterPython::BreakpointCallbackFunction
if (python_function_name != NULL
&& python_function_name[0] != '\0')
{
- Thread *thread = context->exe_ctx.thread;
- const StackFrameSP stop_frame_sp (thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame));
+ const StackFrameSP stop_frame_sp (context->exe_ctx.GetFrameSP());
BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id);
if (breakpoint_sp)
{
diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index a027201f6b8..a8c423f44e6 100644
--- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -103,9 +103,12 @@ AddSymbolicInfo(const ExecutionContext *exe_ctx, ExecutionContextScope *exe_scop
StreamString &comment, uint64_t operand_value, const Address &inst_addr)
{
Address so_addr;
- if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty())
+ Target *target = NULL;
+ if (exe_ctx)
+ target = exe_ctx->GetTargetPtr();
+ if (target && !target->GetSectionLoadList().IsEmpty())
{
- if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress(operand_value, so_addr))
+ if (target->GetSectionLoadList().ResolveLoadAddress(operand_value, so_addr))
so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset);
}
else
@@ -223,8 +226,11 @@ InstructionLLVM::Dump
{
addr_t base_addr = LLDB_INVALID_ADDRESS;
- if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty())
- base_addr = GetAddress().GetLoadAddress (exe_ctx->target);
+ Target *target = NULL;
+ if (exe_ctx)
+ target = exe_ctx->GetTargetPtr();
+ if (target && !target->GetSectionLoadList().IsEmpty())
+ base_addr = GetAddress().GetLoadAddress (target);
if (base_addr == LLDB_INVALID_ADDRESS)
base_addr = GetAddress().GetFileAddress ();
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 10601920214..a2fa14c67c8 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -505,7 +505,7 @@ DynamicLoaderMacOSXDYLD::NotifyBreakpointHit (void *baton,
if (dyld_instance->InitializeFromAllImageInfos())
return dyld_instance->GetStopWhenImagesChange();
- Process *process = context->exe_ctx.process;
+ Process *process = context->exe_ctx.GetProcessPtr();
const lldb::ABISP &abi = process->GetABI();
if (abi != NULL)
{
@@ -524,7 +524,7 @@ DynamicLoaderMacOSXDYLD::NotifyBreakpointHit (void *baton,
input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type);
argument_values.PushValue (input_value);
- if (abi->GetArgumentValues (*context->exe_ctx.thread, argument_values))
+ if (abi->GetArgumentValues (context->exe_ctx.GetThreadRef(), argument_values))
{
uint32_t dyld_mode = argument_values.GetValueAtIndex(0)->GetScalar().UInt (-1);
if (dyld_mode != -1)
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 1dfb3645473..e614edf4be9 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -65,18 +65,19 @@ AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionCon
ExecutionContext exe_ctx;
exe_scope->CalculateExecutionContext(exe_ctx);
-
- if (!exe_ctx.process)
+ Process *process = exe_ctx.GetProcessPtr();
+ if (!process)
return false;
// We need other parts of the exe_ctx, but the processes have to match.
- assert (m_process == exe_ctx.process);
+ assert (m_process == process);
// Get the function address for the print function.
const Address *function_address = GetPrintForDebuggerAddr();
if (!function_address)
return false;
+ Target *target = exe_ctx.GetTargetPtr();
if (value.GetClangType())
{
clang::QualType value_type = clang::QualType::getFromOpaquePtr (value.GetClangType());
@@ -89,7 +90,7 @@ AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionCon
else
{
// If it is not a pointer, see if we can make it into a pointer.
- ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext();
+ ClangASTContext *ast_context = target->GetScratchClangASTContext();
void *opaque_type_ptr = ast_context->GetBuiltInType_objc_id();
if (opaque_type_ptr == NULL)
opaque_type_ptr = ast_context->GetVoidPtrType(false);
@@ -100,7 +101,7 @@ AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionCon
arg_value_list.PushValue(value);
// This is the return value:
- ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext();
+ ClangASTContext *ast_context = target->GetScratchClangASTContext();
void *return_qualtype = ast_context->GetCStringType(true);
Value ret;
@@ -144,7 +145,7 @@ AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionCon
size_t curr_len = full_buffer_len;
while (curr_len == full_buffer_len)
{
- curr_len = exe_ctx.process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf));
+ curr_len = process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf));
strm.Write (buf, curr_len);
cstr_len += curr_len;
}
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index f1efea260d0..739a459eac8 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -398,7 +398,7 @@ AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines (void *baton,
{
// The Update function is called with the address of an added region. So we grab that address, and
// feed it into ReadRegions. Of course, our friend the ABI will get the values for us.
- Process *process = context->exe_ctx.process;
+ Process *process = context->exe_ctx.GetProcessPtr();
const ABI *abi = process->GetABI().get();
ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext();
@@ -409,7 +409,7 @@ AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines (void *baton,
input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type);
argument_values.PushValue(input_value);
- bool success = abi->GetArgumentValues (*(context->exe_ctx.thread), argument_values);
+ bool success = abi->GetArgumentValues (context->exe_ctx.GetThreadRef(), argument_values);
if (!success)
return false;
@@ -878,7 +878,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool sto
{
ConstString our_utility_function_name("__lldb_objc_find_implementation_for_selector");
SymbolContextList sc_list;
- exe_ctx.target->GetImages().FindSymbolsWithNameAndType (our_utility_function_name, eSymbolTypeCode, sc_list);
+
+ exe_ctx.GetTargetRef().GetImages().FindSymbolsWithNameAndType (our_utility_function_name, eSymbolTypeCode, sc_list);
if (sc_list.GetSize() == 1)
{
SymbolContext sc;
@@ -886,7 +887,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool sto
if (sc.symbol != NULL)
impl_code_address = sc.symbol->GetValue();
- //lldb::addr_t addr = impl_code_address.GetOpcodeLoadAddress (exe_ctx.target);
+ //lldb::addr_t addr = impl_code_address.GetOpcodeLoadAddress (exe_ctx.GetTargetPtr());
//printf ("Getting address for our_utility_function: 0x%llx.\n", addr);
}
else
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index 62941bfc232..b373ed9dc57 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -67,9 +67,9 @@ void
AppleThreadPlanStepThroughObjCTrampoline::DidPush ()
{
StreamString errors;
- ExecutionContext exc_context;
- m_thread.CalculateExecutionContext(exc_context);
- m_func_sp.reset(m_impl_function->GetThreadPlanToCallFunction (exc_context, m_args_addr, errors, m_stop_others));
+ ExecutionContext exc_ctx;
+ m_thread.CalculateExecutionContext(exc_ctx);
+ m_func_sp.reset(m_impl_function->GetThreadPlanToCallFunction (exc_ctx, m_args_addr, errors, m_stop_others));
m_func_sp->SetPrivate(true);
m_thread.QueueThreadPlan (m_func_sp, false);
}
@@ -116,13 +116,13 @@ AppleThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr)
if (!m_run_to_sp)
{
Value target_addr_value;
- ExecutionContext exc_context;
- m_thread.CalculateExecutionContext(exc_context);
- m_impl_function->FetchFunctionResults (exc_context, m_args_addr, target_addr_value);
- m_impl_function->DeallocateFunctionResults(exc_context, m_args_addr);
+ ExecutionContext exc_ctx;
+ m_thread.CalculateExecutionContext(exc_ctx);
+ m_impl_function->FetchFunctionResults (exc_ctx, m_args_addr, target_addr_value);
+ m_impl_function->DeallocateFunctionResults(exc_ctx, m_args_addr);
lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong();
Address target_so_addr;
- target_so_addr.SetOpcodeLoadAddress(target_addr, exc_context.target);
+ target_so_addr.SetOpcodeLoadAddress(target_addr, exc_ctx.GetTargetPtr());
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
if (target_addr == 0)
{
diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index 77be2511c3e..20e0292fdd9 100644
--- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -113,7 +113,7 @@ UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly (AddressRange&
m_inst_emulator_ap->SetInstruction (inst->GetOpcode(),
inst->GetAddress(),
- exe_ctx.target);
+ exe_ctx.GetTargetPtr());
m_inst_emulator_ap->EvaluateInstruction (eEmulateInstructionOptionIgnoreConditions);
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 1c0ec1baf09..43996398e1d 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -3114,10 +3114,12 @@ ClangASTContext::GetChildClangTypeAtIndex
// the changing size of base classes that are newer than this class.
// So if we have a process around that we can ask about this object, do so.
child_byte_offset = LLDB_INVALID_IVAR_OFFSET;
-
- if (exe_ctx && exe_ctx->process)
+ Process *process = NULL;
+ if (exe_ctx)
+ process = exe_ctx->GetProcessPtr();
+ if (process)
{
- ObjCLanguageRuntime *objc_runtime = exe_ctx->process->GetObjCLanguageRuntime();
+ ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
if (objc_runtime != NULL)
{
ClangASTType parent_ast_type (ast, parent_qual_type.getAsOpaquePtr());
diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp
index f383323d583..6d9f6dfadad 100644
--- a/lldb/source/Symbol/ClangASTType.cpp
+++ b/lldb/source/Symbol/ClangASTType.cpp
@@ -1132,37 +1132,40 @@ ClangASTType::DumpSummary
clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
if (ClangASTContext::IsCStringType (clang_type, length))
{
-
- if (exe_ctx && exe_ctx->process)
+ if (exe_ctx)
{
- uint32_t offset = data_byte_offset;
- lldb::addr_t pointer_addresss = data.GetMaxU64(&offset, data_byte_size);
- std::vector<uint8_t> buf;
- if (length > 0)
- buf.resize (length);
- else
- buf.resize (256);
-
- lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), exe_ctx->process->GetByteOrder(), 4);
- buf.back() = '\0';
- size_t bytes_read;
- size_t total_cstr_len = 0;
- Error error;
- while ((bytes_read = exe_ctx->process->ReadMemory (pointer_addresss, &buf.front(), buf.size(), error)) > 0)
+ Process *process = exe_ctx->GetProcessPtr();
+ if (process)
{
- const size_t len = strlen((const char *)&buf.front());
- if (len == 0)
- break;
- if (total_cstr_len == 0)
- s->PutCString (" \"");
- cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
- total_cstr_len += len;
- if (len < buf.size())
- break;
- pointer_addresss += total_cstr_len;
+ uint32_t offset = data_byte_offset;
+ lldb::addr_t pointer_addresss = data.GetMaxU64(&offset, data_byte_size);
+ std::vector<uint8_t> buf;
+ if (length > 0)
+ buf.resize (length);
+ else
+ buf.resize (256);
+
+ lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), process->GetByteOrder(), 4);
+ buf.back() = '\0';
+ size_t bytes_read;
+ size_t total_cstr_len = 0;
+ Error error;
+ while ((bytes_read = process->ReadMemory (pointer_addresss, &buf.front(), buf.size(), error)) > 0)
+ {
+ const size_t len = strlen((const char *)&buf.front());
+ if (len == 0)
+ break;
+ if (total_cstr_len == 0)
+ s->PutCString (" \"");
+ cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+ total_cstr_len += len;
+ if (len < buf.size())
+ break;
+ pointer_addresss += total_cstr_len;
+ }
+ if (total_cstr_len > 0)
+ s->PutChar ('"');
}
- if (total_cstr_len > 0)
- s->PutChar ('"');
}
}
}
@@ -1656,10 +1659,13 @@ ClangASTType::ReadFromMemory
}
else
{
- if (exe_ctx && exe_ctx->process)
+ Process *process = NULL;
+ if (exe_ctx)
+ process = exe_ctx->GetProcessPtr();
+ if (process)
{
Error error;
- return exe_ctx->process->ReadMemory(addr, dst, byte_size, error) == byte_size;
+ return process->ReadMemory(addr, dst, byte_size, error) == byte_size;
}
}
}
@@ -1713,10 +1719,13 @@ ClangASTType::WriteToMemory
}
else
{
- if (exe_ctx && exe_ctx->process)
+ Process *process = NULL;
+ if (exe_ctx)
+ process = exe_ctx->GetProcessPtr();
+ if (process)
{
Error error;
- return exe_ctx->process->WriteMemory(addr, new_value.GetData(), byte_size, error) == byte_size;
+ return process->WriteMemory(addr, new_value.GetData(), byte_size, error) == byte_size;
}
}
}
diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp
index dbe15ef9b62..0d4c3d3c234 100644
--- a/lldb/source/Symbol/Type.cpp
+++ b/lldb/source/Symbol/Type.cpp
@@ -357,8 +357,11 @@ Type::DumpValueInMemory
if (address != LLDB_INVALID_ADDRESS)
{
DataExtractor data;
- if (exe_ctx->target)
- data.SetByteOrder (exe_ctx->target->GetArchitecture().GetByteOrder());
+ Target *target = NULL;
+ if (exe_ctx)
+ target = exe_ctx->GetTargetPtr();
+ if (target)
+ data.SetByteOrder (target->GetArchitecture().GetByteOrder());
if (ReadFromMemory (exe_ctx, address, address_type, data))
{
DumpValue(exe_ctx, s, data, 0, show_types, show_summary, verbose);
@@ -397,10 +400,14 @@ Type::ReadFromMemory (ExecutionContext *exe_ctx, lldb::addr_t addr, AddressType
}
else
{
- if (exe_ctx && exe_ctx->process)
+ if (exe_ctx)
{
- Error error;
- return exe_ctx->process->ReadMemory(addr, dst, byte_size, error) == byte_size;
+ Process *process = exe_ctx->GetProcessPtr();
+ if (process)
+ {
+ Error error;
+ return exe_ctx->GetProcessPtr()->ReadMemory(addr, dst, byte_size, error) == byte_size;
+ }
}
}
}
diff --git a/lldb/source/Target/ExecutionContext.cpp b/lldb/source/Target/ExecutionContext.cpp
index 72c041012ed..41cf04d0dbe 100644
--- a/lldb/source/Target/ExecutionContext.cpp
+++ b/lldb/source/Target/ExecutionContext.cpp
@@ -17,36 +17,57 @@
using namespace lldb_private;
ExecutionContext::ExecutionContext() :
- target (NULL),
- process (NULL),
- thread (NULL),
- frame (NULL)
+ m_target_sp (),
+ m_process_sp (),
+ m_thread_sp (),
+ m_frame_sp ()
{
}
+ExecutionContext::ExecutionContext (const ExecutionContext &rhs) :
+ m_target_sp (rhs.m_target_sp),
+ m_process_sp(rhs.m_process_sp),
+ m_thread_sp (rhs.m_thread_sp),
+ m_frame_sp (rhs.m_frame_sp)
+{
+}
+
+ExecutionContext &
+ExecutionContext::operator =(const ExecutionContext &rhs)
+{
+ if (this != &rhs)
+ {
+ m_target_sp = rhs.m_target_sp;
+ m_process_sp = rhs.m_process_sp;
+ m_thread_sp = rhs.m_thread_sp;
+ m_frame_sp = rhs.m_frame_sp;
+ }
+ return *this;
+}
+
ExecutionContext::ExecutionContext (Target* t, bool fill_current_process_thread_frame) :
- target (t),
- process (NULL),
- thread (NULL),
- frame (NULL)
+ m_target_sp (t),
+ m_process_sp (),
+ m_thread_sp (),
+ m_frame_sp ()
{
if (t && fill_current_process_thread_frame)
{
- process = t->GetProcessSP().get();
- if (process)
+ m_process_sp = t->GetProcessSP();
+ if (m_process_sp)
{
- thread = process->GetThreadList().GetSelectedThread().get();
- if (thread)
- frame = thread->GetSelectedFrame().get();
+ m_thread_sp = m_process_sp->GetThreadList().GetSelectedThread();
+ if (m_thread_sp)
+ m_frame_sp = m_thread_sp->GetSelectedFrame().get();
}
}
}
-ExecutionContext::ExecutionContext(Process* p, Thread *t, StackFrame *f) :
- target (p ? &p->GetTarget() : NULL),
- process (p),
- thread (t),
- frame (f)
+ExecutionContext::ExecutionContext(Process* process, Thread *thread, StackFrame *frame) :
+ m_target_sp (process ? &process->GetTarget() : NULL),
+ m_process_sp (process),
+ m_thread_sp (thread),
+ m_frame_sp (frame)
{
}
@@ -56,10 +77,10 @@ ExecutionContext::ExecutionContext (ExecutionContextScope *exe_scope_ptr)
exe_scope_ptr->CalculateExecutionContext (*this);
else
{
- target = NULL;
- process = NULL;
- thread = NULL;
- frame = NULL;
+ m_target_sp.reset();
+ m_process_sp.reset();
+ m_thread_sp.reset();
+ m_frame_sp.reset();
}
}
@@ -71,41 +92,132 @@ ExecutionContext::ExecutionContext (ExecutionContextScope &exe_scope_ref)
void
ExecutionContext::Clear()
{
- target = NULL;
- process = NULL;
- thread = NULL;
- frame = NULL;
+ m_target_sp.reset();
+ m_process_sp.reset();
+ m_thread_sp.reset();
+ m_frame_sp.reset();
+}
+
+ExecutionContext::~ExecutionContext()
+{
}
RegisterContext *
ExecutionContext::GetRegisterContext () const
{
- if (frame)
- return frame->GetRegisterContext().get();
- else if (thread)
- return thread->GetRegisterContext().get();
+ if (m_frame_sp)
+ return m_frame_sp->GetRegisterContext().get();
+ else if (m_thread_sp)
+ return m_thread_sp->GetRegisterContext().get();
return NULL;
}
-ExecutionContextScope *
-ExecutionContext::GetBestExecutionContextScope () const
+Target *
+ExecutionContext::GetTargetPtr () const
{
- if (frame)
- return frame;
- if (thread)
- return thread;
- if (process)
- return process;
- return target;
+ if (m_target_sp)
+ return m_target_sp.get();
+ if (m_process_sp)
+ return &m_process_sp->GetTarget();
+ return NULL;
}
Process *
-ExecutionContext::GetProcess () const
+ExecutionContext::GetProcessPtr () const
{
- if (process)
- return process;
- if (target)
- return target->GetProcessSP().get();
+ if (m_process_sp)
+ return m_process_sp.get();
+ if (m_target_sp)
+ return m_target_sp->GetProcessSP().get();
return NULL;
}
+
+ExecutionContextScope *
+ExecutionContext::GetBestExecutionContextScope () const
+{
+ if (m_frame_sp)
+ return m_frame_sp.get();
+ if (m_thread_sp)
+ return m_thread_sp.get();
+ if (m_process_sp)
+ return m_process_sp.get();
+ return m_target_sp.get();
+}
+
+Target &
+ExecutionContext::GetTargetRef () const
+{
+ assert (m_target_sp.get());
+ return *m_target_sp;
+}
+
+Process &
+ExecutionContext::GetProcessRef () const
+{
+ assert (m_process_sp.get());
+ return *m_process_sp;
+}
+
+Thread &
+ExecutionContext::GetThreadRef () const
+{
+ assert (m_thread_sp.get());
+ return *m_thread_sp;
+}
+
+StackFrame &
+ExecutionContext::GetFrameRef () const
+{
+ assert (m_frame_sp.get());
+ return *m_frame_sp;
+}
+
+void
+ExecutionContext::SetTargetSP (const lldb::TargetSP &target_sp)
+{
+ m_target_sp = target_sp;
+}
+
+void
+ExecutionContext::SetProcessSP (const lldb::ProcessSP &process_sp)
+{
+ m_process_sp = process_sp;
+}
+
+void
+ExecutionContext::SetThreadSP (const lldb::ThreadSP &thread_sp)
+{
+ m_thread_sp = thread_sp;
+}
+
+void
+ExecutionContext::SetFrameSP (const lldb::StackFrameSP &frame_sp)
+{
+ m_frame_sp = frame_sp;
+}
+
+void
+ExecutionContext::SetTargetPtr (Target* target)
+{
+ m_target_sp = target;
+}
+
+void
+ExecutionContext::SetProcessPtr (Process *process)
+{
+ m_process_sp = process;
+}
+
+void
+ExecutionContext::SetThreadPtr (Thread *thread)
+{
+ m_thread_sp = thread;
+}
+
+void
+ExecutionContext::SetFramePtr (StackFrame *frame)
+{
+ m_frame_sp = frame;
+}
+
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index bab1eda3bc1..384f9e84120 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -3128,10 +3128,10 @@ Process::ProcessEventData::SetUpdateStateOnRemoval (Event *event_ptr)
void
Process::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
- exe_ctx.target = &m_target;
- exe_ctx.process = this;
- exe_ctx.thread = NULL;
- exe_ctx.frame = NULL;
+ exe_ctx.SetTargetPtr (&m_target);
+ exe_ctx.SetProcessPtr (this);
+ exe_ctx.SetThreadPtr(NULL);
+ exe_ctx.SetFramePtr (NULL);
}
lldb::ProcessSP
@@ -3368,6 +3368,19 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
errors.Printf("RunThreadPlan called with empty thread plan.");
return eExecutionSetupError;
}
+
+ if (exe_ctx.GetProcessPtr() != this)
+ {
+ errors.Printf("RunThreadPlan called on wrong process.");
+ return eExecutionSetupError;
+ }
+
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (thread == NULL)
+ {
+ errors.Printf("RunThreadPlan called with invalid thread.");
+ return eExecutionSetupError;
+ }
// We rely on the thread plan we are running returning "PlanCompleted" if when it successfully completes.
// For that to be true the plan can't be private - since private plans suppress themselves in the
@@ -3383,13 +3396,13 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
}
// Save the thread & frame from the exe_ctx for restoration after we run
- const uint32_t thread_idx_id = exe_ctx.thread->GetIndexID();
- StackID ctx_frame_id = exe_ctx.thread->GetSelectedFrame()->GetStackID();
+ const uint32_t thread_idx_id = thread->GetIndexID();
+ StackID ctx_frame_id = thread->GetSelectedFrame()->GetStackID();
// N.B. Running the target may unset the currently selected thread and frame. We don't want to do that either,
// so we should arrange to reset them as well.
- lldb::ThreadSP selected_thread_sp = exe_ctx.process->GetThreadList().GetSelectedThread();
+ lldb::ThreadSP selected_thread_sp = GetThreadList().GetSelectedThread();
uint32_t selected_tid;
StackID selected_stack_id;
@@ -3403,7 +3416,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
selected_tid = LLDB_INVALID_THREAD_ID;
}
- exe_ctx.thread->QueueThreadPlan(thread_plan_sp, true);
+ thread->QueueThreadPlan(thread_plan_sp, true);
Listener listener("lldb.process.listener.run-thread-plan");
@@ -3418,8 +3431,8 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
StreamString s;
thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
log->Printf ("Process::RunThreadPlan(): Resuming thread %u - 0x%4.4x to run thread plan \"%s\".",
- exe_ctx.thread->GetIndexID(),
- exe_ctx.thread->GetID(),
+ thread->GetIndexID(),
+ thread->GetID(),
s.GetData());
}
@@ -3443,7 +3456,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
// Do the initial resume and wait for the running event before going further.
- Error resume_error = exe_ctx.process->Resume ();
+ Error resume_error = Resume ();
if (!resume_error.Success())
{
errors.Printf("Error resuming inferior: \"%s\".\n", resume_error.AsCString());
@@ -3522,7 +3535,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
case lldb::eStateStopped:
{
// Yay, we're done. Now make sure that our thread plan actually completed.
- ThreadSP thread_sp = exe_ctx.process->GetThreadList().FindThreadByIndexID (thread_idx_id);
+ ThreadSP thread_sp = GetThreadList().FindThreadByIndexID (thread_idx_id);
if (!thread_sp)
{
// Ooh, our thread has vanished. Unlikely that this was successful execution...
@@ -3614,7 +3627,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
single_thread_timeout_usec);
}
- Error halt_error = exe_ctx.process->Halt();
+ Error halt_error = Halt();
if (halt_error.Success())
{
if (log)
@@ -3643,7 +3656,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
// Between the time we initiated the Halt and the time we delivered it, the process could have
// already finished its job. Check that here:
- if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get()))
+ if (thread->IsThreadPlanDone (thread_plan_sp.get()))
{
if (log)
log->PutCString ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. "
@@ -3717,7 +3730,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
// Between the time we initiated the Halt and the time we delivered it, the process could have
// already finished its job. Check that here:
- if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get()))
+ if (thread->IsThreadPlanDone (thread_plan_sp.get()))
{
if (log)
log->PutCString ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. "
@@ -3845,7 +3858,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (discard_on_error && thread_plan_sp)
{
- exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
+ thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
thread_plan_sp->SetPrivate (orig_plan_private);
}
}
@@ -3857,19 +3870,19 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (discard_on_error && thread_plan_sp)
{
- exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
+ thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
thread_plan_sp->SetPrivate (orig_plan_private);
}
}
else
{
- if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get()))
+ if (thread->IsThreadPlanDone (thread_plan_sp.get()))
{
if (log)
log->PutCString("Process::RunThreadPlan(): thread plan is done");
return_value = eExecutionCompleted;
}
- else if (exe_ctx.thread->WasThreadPlanDiscarded (thread_plan_sp.get()))
+ else if (thread->WasThreadPlanDiscarded (thread_plan_sp.get()))
{
if (log)
log->PutCString("Process::RunThreadPlan(): thread plan was discarded");
@@ -3883,7 +3896,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
if (log)
log->PutCString("Process::RunThreadPlan(): discarding thread plan 'cause discard_on_error is set.");
- exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
+ thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
thread_plan_sp->SetPrivate (orig_plan_private);
}
}
@@ -3892,10 +3905,10 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
// Thread we ran the function in may have gone away because we ran the target
// Check that it's still there, and if it is put it back in the context. Also restore the
// frame in the context if it is still present.
- exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(thread_idx_id, true).get();
- if (exe_ctx.thread)
+ thread = GetThreadList().FindThreadByIndexID(thread_idx_id, true).get();
+ if (thread)
{
- exe_ctx.frame = exe_ctx.thread->GetFrameWithStackID (ctx_frame_id).get();
+ exe_ctx.SetFrameSP (thread->GetFrameWithStackID (ctx_frame_id));
}
// Also restore the current process'es selected frame & thread, since this function calling may
@@ -3903,12 +3916,12 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (selected_tid != LLDB_INVALID_THREAD_ID)
{
- if (exe_ctx.process->GetThreadList().SetSelectedThreadByIndexID (selected_tid) && selected_stack_id.IsValid())
+ if (GetThreadList().SetSelectedThreadByIndexID (selected_tid) && selected_stack_id.IsValid())
{
// We were able to restore the selected thread, now restore the frame:
- StackFrameSP old_frame_sp = exe_ctx.process->GetThreadList().GetSelectedThread()->GetFrameWithStackID(selected_stack_id);
+ StackFrameSP old_frame_sp = GetThreadList().GetSelectedThread()->GetFrameWithStackID(selected_stack_id);
if (old_frame_sp)
- exe_ctx.process->GetThreadList().GetSelectedThread()->SetSelectedFrame(old_frame_sp.get());
+ GetThreadList().GetSelectedThread()->SetSelectedFrame(old_frame_sp.get());
}
}
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index 417be751b9d..f8e1c6fa515 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -1168,7 +1168,7 @@ void
StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
m_thread.CalculateExecutionContext (exe_ctx);
- exe_ctx.frame = this;
+ exe_ctx.SetFramePtr(this);
}
void
diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index 8978f73a0fe..78eed6fe0f6 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -225,7 +225,7 @@ public:
}
else
{
- Debugger &debugger = context.exe_ctx.target->GetDebugger();
+ Debugger &debugger = context.exe_ctx.GetTargetRef().GetDebugger();
StreamSP error_sp = debugger.GetAsyncErrorStream ();
error_sp->Printf ("Stopped due to an error evaluating condition of breakpoint ");
bp_loc_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief);
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 5fdc2333eb8..7fc9257af92 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1177,10 +1177,8 @@ Target::CalculateStackFrame ()
void
Target::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
- exe_ctx.target = this;
- exe_ctx.process = NULL; // Do NOT fill in process...
- exe_ctx.thread = NULL;
- exe_ctx.frame = NULL;
+ exe_ctx.Clear();
+ exe_ctx.SetTargetPtr(this);
}
PathMappingList &
@@ -1278,11 +1276,8 @@ Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const Symbol
Target *target = NULL;
if (sc_ptr != NULL)
target = sc_ptr->target_sp.get();
- if (target == NULL)
- {
- if (exe_ctx_ptr != NULL && exe_ctx_ptr->process != NULL)
- target = &exe_ctx_ptr->process->GetTarget();
- }
+ if (target == NULL && exe_ctx_ptr)
+ target = exe_ctx_ptr->GetTargetPtr();
return target;
}
@@ -1656,7 +1651,7 @@ Target::RunStopHooks ()
if ((cur_hook_sp->GetSpecifier () == NULL
|| cur_hook_sp->GetSpecifier()->SymbolContextMatches(sym_ctx_with_reasons[i]))
&& (cur_hook_sp->GetThreadSpecifier() == NULL
- || cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].thread)))
+ || cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].GetThreadPtr())))
{
if (!hooks_ran)
{
@@ -1670,7 +1665,7 @@ Target::RunStopHooks ()
}
if (print_thread_header)
- result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].thread->GetIndexID());
+ result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].GetThreadPtr()->GetIndexID());
bool stop_on_continue = true;
bool stop_on_error = true;
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index e45851993ba..bed1e2a98f0 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -912,8 +912,8 @@ void
Thread::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
m_process.CalculateExecutionContext (exe_ctx);
- exe_ctx.thread = this;
- exe_ctx.frame = NULL;
+ exe_ctx.SetThreadPtr (this);
+ exe_ctx.SetFramePtr (NULL);
}
@@ -943,16 +943,17 @@ void
Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
{
ExecutionContext exe_ctx;
+ StackFrameSP frame_sp;
SymbolContext frame_sc;
CalculateExecutionContext (exe_ctx);
if (frame_idx != LLDB_INVALID_INDEX32)
{
- StackFrameSP frame_sp(GetStackFrameAtIndex (frame_idx));
+ frame_sp = GetStackFrameAtIndex (frame_idx);
if (frame_sp)
{
- exe_ctx.frame = frame_sp.get();
- frame_sc = exe_ctx.frame->GetSymbolContext(eSymbolContextEverything);
+ exe_ctx.SetFrameSP(frame_sp);
+ frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
}
}
@@ -960,7 +961,7 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
assert (thread_format);
const char *end = NULL;
Debugger::FormatPrompt (thread_format,
- exe_ctx.frame ? &frame_sc : NULL,
+ frame_sp ? &frame_sc : NULL,
&exe_ctx,
NULL,
strm,
diff --git a/lldb/source/Target/ThreadPlanTestCondition.cpp b/lldb/source/Target/ThreadPlanTestCondition.cpp
index 9c17ac3b61a..42aa01cf8b7 100644
--- a/lldb/source/Target/ThreadPlanTestCondition.cpp
+++ b/lldb/source/Target/ThreadPlanTestCondition.cpp
@@ -102,7 +102,7 @@ ThreadPlanTestCondition::ShouldStop (Event *event_ptr)
m_did_stop = true;
}
}
- else if (m_exe_ctx.thread->WasThreadPlanDiscarded (m_expression_plan_sp.get()))
+ else if (m_exe_ctx.GetThreadRef().WasThreadPlanDiscarded (m_expression_plan_sp.get()))
{
if (log)
log->Printf("ExecuteExpression thread plan was discarded.\n");
OpenPOWER on IntegriCloud