Converted the lldb_private::Process over to use the intrusive
shared pointers.
Changed the ExecutionContext over to use shared pointers for
the target, process, thread and frame since these objects can
easily go away at any time and any object that was holding onto
an ExecutionContext was running the risk of using a bad object.
Now that the shared pointers for target, process, thread and
frame are just a single pointer (they all use the instrusive
shared pointers) the execution context is much safer and still
the same size.
Made the shared pointers in the the ExecutionContext class protected
and made accessors for all of the various ways to get at the pointers,
references, and shared pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@140298 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lldb/Expression/ClangExpressionDeclMap.h b/include/lldb/Expression/ClangExpressionDeclMap.h
index dcea151..4ea5b04 100644
--- a/include/lldb/Expression/ClangExpressionDeclMap.h
+++ b/include/lldb/Expression/ClangExpressionDeclMap.h
@@ -701,8 +701,8 @@
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/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h
index 23500f9..4022fee 100644
--- a/include/lldb/Target/ExecutionContext.h
+++ b/include/lldb/Target/ExecutionContext.h
@@ -39,6 +39,10 @@
//------------------------------------------------------------------
ExecutionContext();
+ ExecutionContext (const ExecutionContext &rhs);
+
+ ExecutionContext &
+ operator =(const ExecutionContext &rhs);
ExecutionContext (Target* t, bool fill_current_process_thread_frame = true);
//------------------------------------------------------------------
@@ -64,6 +68,7 @@
ExecutionContext (ExecutionContextScope &exe_scope);
+ ~ExecutionContext();
//------------------------------------------------------------------
/// Clear the object's state.
///
@@ -76,20 +81,95 @@
RegisterContext *
GetRegisterContext () const;
-
ExecutionContextScope *
GetBestExecutionContextScope () const;
-
- Process *
- GetProcess () const;
+ Target *
+ GetTargetPtr () const;
+
+ Process *
+ 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/include/lldb/Target/Process.h b/include/lldb/Target/Process.h
index fbf85a3..3914a72 100644
--- a/include/lldb/Target/Process.h
+++ b/include/lldb/Target/Process.h
@@ -994,6 +994,7 @@
/// @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/include/lldb/lldb-forward-rtti.h b/include/lldb/lldb-forward-rtti.h
index c962a68..d935d6d 100644
--- a/include/lldb/lldb-forward-rtti.h
+++ b/include/lldb/lldb-forward-rtti.h
@@ -54,7 +54,7 @@
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.xcodeproj/project.pbxproj b/lldb.xcodeproj/project.pbxproj
index 28b0c4f..166b0a4 100644
--- a/lldb.xcodeproj/project.pbxproj
+++ b/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/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp
index 9f2e3a1..5e3f3d7 100644
--- a/source/API/SBBreakpoint.cpp
+++ b/source/API/SBBreakpoint.cpp
@@ -487,22 +487,24 @@
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 @@
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/source/API/SBFunction.cpp b/source/API/SBFunction.cpp
index de9f6ae..e037f83 100644
--- a/source/API/SBFunction.cpp
+++ b/source/API/SBFunction.cpp
@@ -131,7 +131,7 @@
{
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/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp
index 0a5594a..0be59af 100644
--- a/source/API/SBInstruction.cpp
+++ b/source/API/SBInstruction.cpp
@@ -122,7 +122,7 @@
{
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/source/Breakpoint/BreakpointOptions.cpp b/source/Breakpoint/BreakpointOptions.cpp
index df41339..16e7101 100644
--- a/source/Breakpoint/BreakpointOptions.cpp
+++ b/source/Breakpoint/BreakpointOptions.cpp
@@ -180,7 +180,8 @@
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 @@
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 @@
// 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/source/Commands/CommandObjectArgs.cpp b/source/Commands/CommandObjectArgs.cpp
index bfa1006..c0f9454 100644
--- a/source/Commands/CommandObjectArgs.cpp
+++ b/source/Commands/CommandObjectArgs.cpp
@@ -105,7 +105,7 @@
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 @@
return false;
}
- Thread *thread = m_interpreter.GetExecutionContext ().thread;
+ Thread *thread = m_interpreter.GetExecutionContext ().GetThreadPtr();
if (!thread)
{
diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp
index cc2051d..f528dfd 100644
--- a/source/Commands/CommandObjectBreakpoint.cpp
+++ b/source/Commands/CommandObjectBreakpoint.cpp
@@ -293,7 +293,7 @@
// 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/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp
index c68f54c..5130a2f 100644
--- a/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -803,10 +803,11 @@
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/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp
index 8115a87..5c7b485 100644
--- a/source/Commands/CommandObjectDisassemble.cpp
+++ b/source/Commands/CommandObjectDisassemble.cpp
@@ -314,15 +314,16 @@
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 @@
}
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 @@
{
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 @@
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 @@
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/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp
index cd6474c..2bacdbb 100644
--- a/source/Commands/CommandObjectExpression.cpp
+++ b/source/Commands/CommandObjectExpression.cpp
@@ -271,7 +271,8 @@
CommandReturnObject *result
)
{
- if (m_exe_ctx.target)
+ Target *target = m_exe_ctx.GetTargetPtr();
+ if (target)
{
lldb::ValueObjectSP result_valobj_sp;
@@ -283,7 +284,7 @@
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 @@
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/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index 4982bfb..555afc3 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -74,9 +74,10 @@
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 @@
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 @@
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 @@
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 @@
)
{
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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp
index f6a1846..9629c84 100644
--- a/source/Commands/CommandObjectMemory.cpp
+++ b/source/Commands/CommandObjectMemory.cpp
@@ -351,7 +351,8 @@
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 @@
}
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 @@
}
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 @@
}
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 @@
{
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 @@
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 @@
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/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
index ed6c7f9..e868f27 100644
--- a/source/Commands/CommandObjectPlatform.cpp
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -373,7 +373,7 @@
{
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/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 3145984..980f9d2 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -174,7 +174,7 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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/source/Commands/CommandObjectRegister.cpp b/source/Commands/CommandObjectRegister.cpp
index 730c74e..73c9c8b 100644
--- a/source/Commands/CommandObjectRegister.cpp
+++ b/source/Commands/CommandObjectRegister.cpp
@@ -99,7 +99,7 @@
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/source/Commands/CommandObjectSource.cpp b/source/Commands/CommandObjectSource.cpp
index aba27c1..dae2e7b 100644
--- a/source/Commands/CommandObjectSource.cpp
+++ b/source/Commands/CommandObjectSource.cpp
@@ -280,11 +280,9 @@
}
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 @@
{
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/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index 8347d00..9954954 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -649,8 +649,8 @@
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 @@
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 @@
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 @@
{
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 @@
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 @@
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 @@
{
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 @@
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/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp
index 292b963..68de872 100644
--- a/source/Commands/CommandObjectThread.cpp
+++ b/source/Commands/CommandObjectThread.cpp
@@ -163,13 +163,14 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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/source/Core/Address.cpp b/source/Core/Address.cpp
index 200ef4c..ffb90c9 100644
--- a/source/Core/Address.cpp
+++ b/source/Core/Address.cpp
@@ -108,9 +108,10 @@
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/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index c101038..83c226b 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -337,22 +337,22 @@
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 @@
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 @@
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)
+ Process *process = exe_ctx->GetProcessPtr();
+ if (process)
{
- 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))
- {
- 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')
+ 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.GetFilename() = exe_module->GetFileSpec().GetFilename();
- var_success = format_file_spec;
- }
- else
- {
- 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)
+ Thread *thread = exe_ctx->GetThreadPtr();
+ if (thread)
{
- 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)
- {
- 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 @@
}
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)
+ StackFrame *frame = exe_ctx->GetFramePtr();
+ if (frame)
{
- 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)
- {
- 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)
{
- var_name_begin += ::strlen ("reg.");
- if (var_name_begin < var_name_end)
+ s.Printf("%u", 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)
+ {
+ 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 @@
}
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 @@
// 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/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index 4d82479..4ebe688 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -81,15 +81,16 @@
{
// 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 @@
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 @@
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 @@
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 @@
)
{
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 @@
}
else
{
- range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress();
+ range.GetBaseAddress() = frame->GetFrameCodeAddress();
}
if (range.GetBaseAddress().IsValid() && range.GetByteSize() == 0)
@@ -848,32 +852,34 @@
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 @@
{
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/source/Core/FormatClasses.cpp b/source/Core/FormatClasses.cpp
index ee68930..b0c58ac 100644
--- a/source/Core/FormatClasses.cpp
+++ b/source/Core/FormatClasses.cpp
@@ -84,8 +84,9 @@
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/source/Core/SearchFilter.cpp b/source/Core/SearchFilter.cpp
index 1d38c41..835072a 100644
--- a/source/Core/SearchFilter.cpp
+++ b/source/Core/SearchFilter.cpp
@@ -583,7 +583,7 @@
}
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/source/Core/Value.cpp b/source/Core/Value.cpp
index 897ab8c..c380d76 100644
--- a/source/Core/Value.cpp
+++ b/source/Core/Value.cpp
@@ -366,7 +366,7 @@
}
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 @@
{
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 @@
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 @@
// 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 @@
// 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/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp
index 1d3b749..71180bc 100644
--- a/source/Core/ValueObject.cpp
+++ b/source/Core/ValueObject.cpp
@@ -3439,22 +3439,21 @@
// 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();
+ m_target_sp = target;
+ m_process_sp = exe_ctx.GetProcessSP();
+ if (!m_process_sp)
+ m_process_sp = target->GetProcessSP();
- if (exe_ctx.process == NULL)
- m_process_sp = exe_ctx.target->GetProcessSP();
- else
- m_process_sp = exe_ctx.process->GetSP();
-
- 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 @@
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 @@
}
}
else
- m_stack_id = exe_ctx.frame->GetStackID();
+ m_stack_id = frame->GetStackID();
}
}
}
diff --git a/source/Core/ValueObjectDynamicValue.cpp b/source/Core/ValueObjectDynamicValue.cpp
index 3dd360d..c053362 100644
--- a/source/Core/ValueObjectDynamicValue.cpp
+++ b/source/Core/ValueObjectDynamicValue.cpp
@@ -127,11 +127,11 @@
}
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/source/Core/ValueObjectMemory.cpp b/source/Core/ValueObjectMemory.cpp
index 098c0fb..bd7a791 100644
--- a/source/Core/ValueObjectMemory.cpp
+++ b/source/Core/ValueObjectMemory.cpp
@@ -185,10 +185,11 @@
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 @@
// 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/source/Core/ValueObjectVariable.cpp b/source/Core/ValueObjectVariable.cpp
index 5717406..bc5dd26 100644
--- a/source/Core/ValueObjectVariable.cpp
+++ b/source/Core/ValueObjectVariable.cpp
@@ -126,10 +126,11 @@
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 @@
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 @@
// 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 @@
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/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 763546b..42c6f7a 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -69,27 +69,30 @@
{
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 @@
TargetInfo ret;
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
-
- if (exe_ctx->process)
+ if (exe_ctx)
{
- ret.byte_order = exe_ctx->process->GetByteOrder();
- ret.address_byte_size = exe_ctx->process->GetAddressByteSize();
- }
- else if (exe_ctx->target)
- {
- 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
{
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
// 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 @@
}
else
{
- Error deallocate_error = exe_ctx.process->DeallocateMemory(mem);
+ Error deallocate_error = process->DeallocateMemory(mem);
if (!err.Success())
{
@@ -1488,7 +1538,7 @@
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 @@
// 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 @@
{
// 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 @@
)
{
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 @@
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 @@
{
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 @@
{
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 @@
// 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 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
// 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 @@
{
// 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 @@
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 @@
{
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 3549196..e674565 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -463,9 +463,9 @@
if (decl_map)
{
Stream *error_stream = NULL;
-
- if (exe_ctx.target)
- error_stream = &exe_ctx.target->GetDebugger().GetErrorStream();
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target)
+ error_stream = &target->GetDebugger().GetErrorStream();
IRForTarget ir_for_target(decl_map,
m_expr.NeedsVariableResolution(),
@@ -489,7 +489,9 @@
return err;
}
- if (!exe_ctx.process || execution_policy == eExecutionPolicyNever)
+ Process *process = exe_ctx.GetProcessPtr();
+
+ if (!process || execution_policy == eExecutionPolicyNever)
{
err.SetErrorToGenericError();
err.SetErrorString("Execution needed to run in the target, but the target can't be run");
@@ -498,9 +500,9 @@
if (execution_policy != eExecutionPolicyNever &&
m_expr.NeedsValidation() &&
- exe_ctx.process)
+ process)
{
- if (!exe_ctx.process->GetDynamicCheckers())
+ if (!process->GetDynamicCheckers())
{
DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
@@ -516,13 +518,13 @@
return err;
}
- exe_ctx.process->SetDynamicCheckers(dynamic_checkers);
+ process->SetDynamicCheckers(dynamic_checkers);
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers ==");
}
- IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), function_name.c_str());
+ IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(), function_name.c_str());
if (!ir_dynamic_checks.runOnModule(*module))
{
@@ -586,9 +588,9 @@
m_jitted_functions.push_back (ClangExpressionParser::JittedFunction(function_name.c_str(), (lldb::addr_t)fun_ptr));
- ExecutionContext &exc_context(exe_ctx);
-
- if (exc_context.process == NULL)
+
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process == NULL)
{
err.SetErrorToGenericError();
err.SetErrorString("Couldn't write the JIT compiled code into the target because there is no target");
@@ -615,7 +617,7 @@
}
Error alloc_error;
- func_allocation_addr = exc_context.process->AllocateMemory (alloc_size,
+ func_allocation_addr = process->AllocateMemory (alloc_size,
lldb::ePermissionsReadable|lldb::ePermissionsExecutable,
alloc_error);
@@ -636,7 +638,7 @@
Error write_error;
- if (exc_context.process->WriteMemory(cursor, (void *) lstart, size, write_error) != size)
+ if (process->WriteMemory(cursor, (void *) lstart, size, write_error) != size)
{
err.SetErrorToGenericError();
err.SetErrorStringWithFormat("Couldn't copy JIT code for function into the target: %s", write_error.AsCString("unknown error"));
@@ -731,7 +733,8 @@
if (log)
log->Printf("Function's code range is [0x%llx-0x%llx]", func_range.first, func_range.second);
- if (!exe_ctx.target)
+ Target *target = exe_ctx.GetTargetPtr();
+ if (!target)
{
ret.SetErrorToGenericError();
ret.SetErrorString("Couldn't find the target");
@@ -739,8 +742,9 @@
lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second - func_remote_addr, 0));
+ Process *process = exe_ctx.GetProcessPtr();
Error err;
- exe_ctx.process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err);
+ process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err);
if (!err.Success())
{
@@ -749,7 +753,7 @@
return ret;
}
- ArchSpec arch(exe_ctx.target->GetArchitecture());
+ ArchSpec arch(target->GetArchitecture());
Disassembler *disassembler = Disassembler::FindPlugin(arch, NULL);
@@ -760,7 +764,7 @@
return ret;
}
- if (!exe_ctx.process)
+ if (!process)
{
ret.SetErrorToGenericError();
ret.SetErrorString("Couldn't find the process");
@@ -768,8 +772,8 @@
}
DataExtractor extractor(buffer_sp,
- exe_ctx.process->GetByteOrder(),
- exe_ctx.target->GetArchitecture().GetAddressByteSize());
+ process->GetByteOrder(),
+ target->GetArchitecture().GetAddressByteSize());
if (log)
{
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index 21acb5b..642463d 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -237,7 +237,7 @@
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 @@
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 @@
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 @@
}
// 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 @@
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 @@
// 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 @@
// 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 @@
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 @@
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/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
index 194ad95..73ed043 100644
--- a/source/Expression/ClangUserExpression.cpp
+++ b/source/Expression/ClangUserExpression.cpp
@@ -80,12 +80,13 @@
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 @@
// Set up the target and compiler
//
- Target *target = exe_ctx.target;
+ Target *target = exe_ctx.GetTargetPtr();
if (!target)
{
@@ -268,7 +269,8 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
}
}
- 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/source/Expression/ClangUtilityFunction.cpp b/source/Expression/ClangUtilityFunction.cpp
index 0d11c91..6f31d4c 100644
--- a/source/Expression/ClangUtilityFunction.cpp
+++ b/source/Expression/ClangUtilityFunction.cpp
@@ -77,7 +77,7 @@
// Set up the target and compiler
//
- Target *target = exe_ctx.target;
+ Target *target = exe_ctx.GetTargetPtr();
if (!target)
{
@@ -85,7 +85,7 @@
return false;
}
- Process *process = exe_ctx.process;
+ Process *process = exe_ctx.GetProcessPtr();
if (!process)
{
@@ -101,7 +101,7 @@
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 @@
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/source/Expression/DWARFExpression.cpp b/source/Expression/DWARFExpression.cpp
index 037fbc1..9b7f93e 100644
--- a/source/Expression/DWARFExpression.cpp
+++ b/source/Expression/DWARFExpression.cpp
@@ -930,10 +930,14 @@
{
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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/source/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp
index 22624ea..2af5e5e 100644
--- a/source/Expression/IRDynamicChecks.cpp
+++ b/source/Expression/IRDynamicChecks.cpp
@@ -56,9 +56,11 @@
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/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index d2aa0dd..4b4c79a 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -1856,8 +1856,12 @@
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 @@
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/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index eb1c921..56f9eec 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -232,7 +232,7 @@
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/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 4557883..e4c2b66 100644
--- a/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -138,7 +138,7 @@
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/source/Interpreter/ScriptInterpreterPython.cpp b/source/Interpreter/ScriptInterpreterPython.cpp
index 6b5fe71..634f76d 100644
--- a/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/source/Interpreter/ScriptInterpreterPython.cpp
@@ -314,9 +314,9 @@
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 @@
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 @@
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 @@
if (!context)
return true;
- Target *target = context->exe_ctx.target;
+ Target *target = context->exe_ctx.GetTargetPtr();
if (!target)
return true;
@@ -1575,8 +1575,7 @@
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/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index a027201..a8c423f 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -103,9 +103,12 @@
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 @@
{
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/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 1060192..a2fa14c 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -505,7 +505,7 @@
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 @@
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/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 1dfb364..e614edf 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -65,18 +65,19 @@
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 @@
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 @@
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 @@
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/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index f1efea2..739a459 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -398,7 +398,7 @@
{
// 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 @@
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 @@
{
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 @@
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/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index 62941bf..b373ed9 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -67,9 +67,9 @@
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 @@
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/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index 77be251..20e0292 100644
--- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -113,7 +113,7 @@
m_inst_emulator_ap->SetInstruction (inst->GetOpcode(),
inst->GetAddress(),
- exe_ctx.target);
+ exe_ctx.GetTargetPtr());
m_inst_emulator_ap->EvaluateInstruction (eEmulateInstructionOptionIgnoreConditions);
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 1c0ec1b..4399639 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -3114,10 +3114,12 @@
// 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/source/Symbol/ClangASTType.cpp b/source/Symbol/ClangASTType.cpp
index f383323..6d9f6df 100644
--- a/source/Symbol/ClangASTType.cpp
+++ b/source/Symbol/ClangASTType.cpp
@@ -1132,37 +1132,40 @@
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 @@
}
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 @@
}
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/source/Symbol/Type.cpp b/source/Symbol/Type.cpp
index dbe15ef..0d4c3d3 100644
--- a/source/Symbol/Type.cpp
+++ b/source/Symbol/Type.cpp
@@ -357,8 +357,11 @@
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 @@
}
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/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index 72c0410..41cf04d 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/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 @@
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 @@
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;
+}
+
+Target *
+ExecutionContext::GetTargetPtr () const
+{
+ if (m_target_sp)
+ return m_target_sp.get();
+ if (m_process_sp)
+ return &m_process_sp->GetTarget();
+ return NULL;
+}
+
+Process *
+ExecutionContext::GetProcessPtr () const
+{
+ 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 (frame)
- return frame;
- if (thread)
- return thread;
- if (process)
- return process;
- return target;
+ 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();
}
-Process *
-ExecutionContext::GetProcess () const
+Target &
+ExecutionContext::GetTargetRef () const
{
- if (process)
- return process;
- if (target)
- return target->GetProcessSP().get();
- return NULL;
+ 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/source/Target/Process.cpp b/source/Target/Process.cpp
index bab1eda..384f9e8 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -3128,10 +3128,10 @@
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 @@
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 @@
}
// 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 @@
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 @@
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 @@
{
// 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 @@
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 @@
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 @@
// 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 @@
// 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 @@
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 @@
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 @@
{
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 @@
// 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 @@
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/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 417be75..f8e1c6f 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -1168,7 +1168,7 @@
StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
m_thread.CalculateExecutionContext (exe_ctx);
- exe_ctx.frame = this;
+ exe_ctx.SetFramePtr(this);
}
void
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 8978f73..78eed6f 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -225,7 +225,7 @@
}
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/source/Target/Target.cpp b/source/Target/Target.cpp
index 5fdc233..7fc9257 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -1177,10 +1177,8 @@
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 *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 @@
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 @@
}
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/source/Target/Thread.cpp b/source/Target/Thread.cpp
index e458519..bed1e2a 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -912,8 +912,8 @@
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 @@
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 @@
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/source/Target/ThreadPlanTestCondition.cpp b/source/Target/ThreadPlanTestCondition.cpp
index 9c17ac3..42aa01c 100644
--- a/source/Target/ThreadPlanTestCondition.cpp
+++ b/source/Target/ThreadPlanTestCondition.cpp
@@ -102,7 +102,7 @@
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");