summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins')
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp17
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp53
-rw-r--r--lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp13
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp10
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp7
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp2
-rw-r--r--lldb/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp2
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp2
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp48
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp42
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp78
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h8
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp46
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp24
-rw-r--r--lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp20
-rw-r--r--lldb/source/Plugins/Process/Utility/ThreadMemory.cpp53
-rw-r--r--lldb/source/Plugins/Process/Utility/ThreadMemory.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp9
-rw-r--r--lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp48
-rw-r--r--lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h4
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp63
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h6
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp8
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp128
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h14
-rw-r--r--lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp2
-rw-r--r--lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp64
-rw-r--r--lldb/source/Plugins/Process/mach-core/ThreadMachCore.h9
-rw-r--r--lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp5
-rw-r--r--lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h3
-rw-r--r--lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp54
-rw-r--r--lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h3
32 files changed, 498 insertions, 353 deletions
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
index 3477695425f..5e6d27b0d64 100644
--- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
+++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
@@ -264,14 +264,14 @@ ABIMacOSX_arm::PrepareTrivialCall (Thread &thread,
}
- Target *target = &thread.GetProcess().GetTarget();
+ TargetSP target_sp (thread.CalculateTarget());
Address so_addr;
// Figure out if our return address is ARM or Thumb by using the
// Address::GetCallableLoadAddress(Target*) which will figure out the ARM
// thumb-ness and set the correct address bits for us.
- so_addr.SetLoadAddress (return_addr, target);
- return_addr = so_addr.GetCallableLoadAddress (target);
+ so_addr.SetLoadAddress (return_addr, target_sp.get());
+ return_addr = so_addr.GetCallableLoadAddress (target_sp.get());
// Set "lr" to the return address
if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_num, return_addr))
@@ -283,8 +283,8 @@ ABIMacOSX_arm::PrepareTrivialCall (Thread &thread,
// If bit zero or 1 is set, this must be a thumb function, no need to figure
// this out from the symbols.
- so_addr.SetLoadAddress (function_addr, target);
- function_addr = so_addr.GetCallableLoadAddress (target);
+ so_addr.SetLoadAddress (function_addr, target_sp.get());
+ function_addr = so_addr.GetCallableLoadAddress (target_sp.get());
const RegisterInfo *cpsr_reg_info = reg_ctx->GetRegisterInfoByName("cpsr");
const uint32_t curr_cpsr = reg_ctx->ReadRegisterAsUnsigned(cpsr_reg_info, 0);
@@ -319,10 +319,11 @@ ABIMacOSX_arm::GetArgumentValues (Thread &thread,
uint32_t num_values = values.GetSize();
+ ExecutionContext exe_ctx (thread.shared_from_this());
// For now, assume that the types in the AST values come from the Target's
// scratch AST.
- clang::ASTContext *ast_context = thread.CalculateTarget()->GetScratchClangASTContext()->getASTContext();
+ clang::ASTContext *ast_context = exe_ctx.GetTargetRef().GetScratchClangASTContext()->getASTContext();
// Extract the register context so we can read arguments from registers
@@ -364,7 +365,7 @@ ABIMacOSX_arm::GetArgumentValues (Thread &thread,
return false;
}
- if (bit_width <= (thread.GetProcess().GetAddressByteSize() * 8))
+ if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8))
{
if (value_idx < 4)
{
@@ -407,7 +408,7 @@ ABIMacOSX_arm::GetArgumentValues (Thread &thread,
// Arguments 5 on up are on the stack
const uint32_t arg_byte_size = (bit_width + (8-1)) / 8;
Error error;
- if (!thread.GetProcess().ReadScalarIntegerFromMemory(sp, arg_byte_size, is_signed, value->GetScalar(), error))
+ if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory(sp, arg_byte_size, is_signed, value->GetScalar(), error))
return false;
sp += arg_byte_size;
diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
index a8f407d042b..f31e1a7e9fe 100644
--- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
@@ -418,9 +418,12 @@ ABIMacOSX_i386::PrepareNormalCall (Thread &thread,
addr_t return_addr,
ValueList &args) const
{
+ ExecutionContext exe_ctx (thread.shared_from_this());
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
if (!reg_ctx)
return false;
+
+ Process *process = exe_ctx.GetProcessPtr();
Error error;
uint32_t fp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
@@ -528,7 +531,7 @@ ABIMacOSX_i386::PrepareNormalCall (Thread &thread,
sp -= (cstr_length + 1);
- if (thread.GetProcess().WriteMemory(sp, cstr, cstr_length + 1, error) != (cstr_length + 1))
+ if (process->WriteMemory(sp, cstr, cstr_length + 1, error) != (cstr_length + 1))
return false;
// Put the address of the string into the argument array.
@@ -563,14 +566,14 @@ ABIMacOSX_i386::PrepareNormalCall (Thread &thread,
size_t numChunks = argLayout.size();
for (index = 0; index < numChunks; ++index)
- if (thread.GetProcess().WriteMemory(sp + (index * 4), &argLayout[index], sizeof(uint32_t), error) != sizeof(uint32_t))
+ if (process->WriteMemory(sp + (index * 4), &argLayout[index], sizeof(uint32_t), error) != sizeof(uint32_t))
return false;
// The return address is pushed onto the stack.
sp -= 4;
uint32_t returnAddressU32 = return_addr;
- if (thread.GetProcess().WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32))
+ if (process->WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32))
return false;
// %esp is set to the actual stack value.
@@ -595,13 +598,13 @@ static bool
ReadIntegerArgument (Scalar &scalar,
unsigned int bit_width,
bool is_signed,
- Process &process,
+ Process *process,
addr_t &current_stack_argument)
{
uint32_t byte_size = (bit_width + (8-1))/8;
Error error;
- if (process.ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error))
+ if (process->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error))
{
current_stack_argument += byte_size;
return true;
@@ -652,29 +655,29 @@ ABIMacOSX_i386::GetArgumentValues (Thread &thread,
default:
return false;
case Value::eContextTypeClangType:
- {
- void *value_type = value->GetClangType();
- bool is_signed;
-
- if (ClangASTContext::IsIntegerType (value_type, is_signed))
{
- size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type);
+ void *value_type = value->GetClangType();
+ bool is_signed;
- ReadIntegerArgument(value->GetScalar(),
- bit_width,
- is_signed,
- thread.GetProcess(),
- current_stack_argument);
- }
- else if (ClangASTContext::IsPointerType (value_type))
- {
- ReadIntegerArgument(value->GetScalar(),
- 32,
- false,
- thread.GetProcess(),
- current_stack_argument);
+ if (ClangASTContext::IsIntegerType (value_type, is_signed))
+ {
+ size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type);
+
+ ReadIntegerArgument(value->GetScalar(),
+ bit_width,
+ is_signed,
+ thread.GetProcess().get(),
+ current_stack_argument);
+ }
+ else if (ClangASTContext::IsPointerType (value_type))
+ {
+ ReadIntegerArgument(value->GetScalar(),
+ 32,
+ false,
+ thread.GetProcess().get(),
+ current_stack_argument);
+ }
}
- }
break;
}
}
diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
index cd8b7b8cd09..9de0cf2dc39 100644
--- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -450,7 +450,7 @@ static bool ReadIntegerArgument(Scalar &scalar,
{
uint32_t byte_size = (bit_width + (8-1))/8;
Error error;
- if (thread.GetProcess().ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error))
+ if (thread.GetProcess()->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error))
{
current_stack_argument += byte_size;
return true;
@@ -690,12 +690,11 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread,
}
ValueObjectSP
-ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread,
- ClangASTType &ast_type) const
+ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &ast_type) const
{
-
ValueObjectSP return_valobj_sp;
+ ExecutionContext exe_ctx (thread.shared_from_this());
return_valobj_sp = GetReturnValueObjectSimple(thread, ast_type);
if (return_valobj_sp)
return return_valobj_sp;
@@ -715,15 +714,15 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread,
size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, ret_value_type);
if (ClangASTContext::IsAggregateType(ret_value_type))
{
- Target &target = thread.GetProcess().GetTarget();
+ Target *target = exe_ctx.GetTargetPtr();
bool is_memory = true;
if (bit_width <= 128)
{
- ByteOrder target_byte_order = target.GetArchitecture().GetByteOrder();
+ ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder();
DataBufferSP data_sp (new DataBufferHeap(16, 0));
DataExtractor return_ext (data_sp,
target_byte_order,
- target.GetArchitecture().GetAddressByteSize());
+ target->GetArchitecture().GetAddressByteSize());
const RegisterInfo *rax_info = reg_ctx_sp->GetRegisterInfoByName("rax", 0);
const RegisterInfo *rdx_info = reg_ctx_sp->GetRegisterInfoByName("rdx", 0);
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index e3c48e2f85c..e77f948cba8 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -546,7 +546,8 @@ DynamicLoaderMacOSXDYLD::NotifyBreakpointHit (void *baton,
if (dyld_instance->InitializeFromAllImageInfos())
return dyld_instance->GetStopWhenImagesChange();
- Process *process = context->exe_ctx.GetProcessPtr();
+ ExecutionContext exe_ctx (context->exe_ctx_ref);
+ Process *process = exe_ctx.GetProcessPtr();
const lldb::ABISP &abi = process->GetABI();
if (abi != NULL)
{
@@ -565,7 +566,7 @@ DynamicLoaderMacOSXDYLD::NotifyBreakpointHit (void *baton,
input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type);
argument_values.PushValue (input_value);
- if (abi->GetArgumentValues (context->exe_ctx.GetThreadRef(), argument_values))
+ if (abi->GetArgumentValues (exe_ctx.GetThreadRef(), argument_values))
{
uint32_t dyld_mode = argument_values.GetValueAtIndex(0)->GetScalar().UInt (-1);
if (dyld_mode != -1)
@@ -1555,7 +1556,8 @@ DynamicLoaderMacOSXDYLD::GetStepThroughTrampolinePlan (Thread &thread, bool stop
if (trampoline_name)
{
SymbolContextList target_symbols;
- ModuleList &images = thread.GetProcess().GetTarget().GetImages();
+ TargetSP target_sp (thread.CalculateTarget());
+ ModuleList &images = target_sp->GetImages();
images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode, target_symbols);
@@ -1611,7 +1613,7 @@ DynamicLoaderMacOSXDYLD::GetStepThroughTrampolinePlan (Thread &thread, bool stop
if (target_symbols.GetContextAtIndex(i, context))
{
context.GetAddressRange (eSymbolContextEverything, 0, false, addr_range);
- lldb::addr_t load_addr = addr_range.GetBaseAddress().GetLoadAddress(&thread.GetProcess().GetTarget());
+ lldb::addr_t load_addr = addr_range.GetBaseAddress().GetLoadAddress(target_sp.get());
addresses[i] = load_addr;
}
}
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index 396a285aed6..5a9d2ab8fcf 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -400,7 +400,8 @@ AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines (void *baton,
{
// The Update function is called with the address of an added region. So we grab that address, and
// feed it into ReadRegions. Of course, our friend the ABI will get the values for us.
- Process *process = context->exe_ctx.GetProcessPtr();
+ ExecutionContext exe_ctx (context->exe_ctx_ref);
+ Process *process = exe_ctx.GetProcessPtr();
const ABI *abi = process->GetABI().get();
ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext();
@@ -411,14 +412,14 @@ AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines (void *baton,
input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type);
argument_values.PushValue(input_value);
- bool success = abi->GetArgumentValues (context->exe_ctx.GetThreadRef(), argument_values);
+ bool success = abi->GetArgumentValues (exe_ctx.GetThreadRef(), argument_values);
if (!success)
return false;
// Now get a pointer value from the zeroth argument.
Error error;
DataExtractor data;
- error = argument_values.GetValueAtIndex(0)->GetValueAsData (&(context->exe_ctx),
+ error = argument_values.GetValueAtIndex(0)->GetValueAsData (&exe_ctx,
clang_ast_context->getASTContext(),
data,
0,
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index b373ed9dc57..cf18214d09d 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -152,7 +152,7 @@ AppleThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr)
if (log)
log->Printf("Running to ObjC method implementation: 0x%llx", target_addr);
- ObjCLanguageRuntime *objc_runtime = GetThread().GetProcess().GetObjCLanguageRuntime();
+ ObjCLanguageRuntime *objc_runtime = GetThread().GetProcess()->GetObjCLanguageRuntime();
assert (objc_runtime != NULL);
objc_runtime->AddToMethodCache (m_isa_addr, m_sel_addr, target_addr);
if (log)
diff --git a/lldb/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp b/lldb/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp
index 8294861365f..7315a825071 100644
--- a/lldb/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp
+++ b/lldb/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp
@@ -249,7 +249,7 @@ OperatingSystemDarwinKernel::UpdateThreadList (ThreadList &old_thread_list, Thre
ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false));
if (!thread_sp)
- thread_sp.reset (new ThreadMemory (*m_process, tid, valobj_sp));
+ thread_sp.reset (new ThreadMemory (m_process->shared_from_this(), tid, valobj_sp));
new_thread_list.AddThread(thread_sp);
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index ab872f8e7d7..3b45691d2e0 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -312,7 +312,7 @@ ProcessKDP::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_threa
lldb::tid_t tid = cpu_mask_bit;
ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false));
if (!thread_sp)
- thread_sp.reset(new ThreadKDP (*this, tid));
+ thread_sp.reset(new ThreadKDP (shared_from_this(), tid));
new_thread_list.AddThread(thread_sp);
}
return new_thread_list.GetSize(false);
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp
index fdd22b2f3b3..296fbbac7e9 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp
@@ -33,11 +33,15 @@ RegisterContextKDP_arm::~RegisterContextKDP_arm()
int
RegisterContextKDP_arm::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
{
- Error error;
- if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
+ ProcessSP process_sp (CalculateProcess());
+ if (process_sp)
{
- if (error.Success())
- return 0;
+ Error error;
+ if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
+ {
+ if (error.Success())
+ return 0;
+ }
}
return -1;
}
@@ -45,11 +49,15 @@ RegisterContextKDP_arm::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
int
RegisterContextKDP_arm::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
{
- Error error;
- if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
+ ProcessSP process_sp (CalculateProcess());
+ if (process_sp)
{
- if (error.Success())
- return 0;
+ Error error;
+ if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
+ {
+ if (error.Success())
+ return 0;
+ }
}
return -1;
}
@@ -57,11 +65,15 @@ RegisterContextKDP_arm::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
int
RegisterContextKDP_arm::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
{
- Error error;
- if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
+ ProcessSP process_sp (CalculateProcess());
+ if (process_sp)
{
- if (error.Success())
- return 0;
+ Error error;
+ if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
+ {
+ if (error.Success())
+ return 0;
+ }
}
return -1;
}
@@ -69,11 +81,15 @@ RegisterContextKDP_arm::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
int
RegisterContextKDP_arm::DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg)
{
- Error error;
- if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, DBGRegSet, &dbg, sizeof(dbg), error))
+ ProcessSP process_sp (CalculateProcess());
+ if (process_sp)
{
- if (error.Success())
- return 0;
+ Error error;
+ if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, DBGRegSet, &dbg, sizeof(dbg), error))
+ {
+ if (error.Success())
+ return 0;
+ }
}
return -1;
}
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp
index 503ce75181c..504ea07ba4f 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp
@@ -33,11 +33,15 @@ RegisterContextKDP_i386::~RegisterContextKDP_i386()
int
RegisterContextKDP_i386::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
{
- Error error;
- if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
+ ProcessSP process_sp (CalculateProcess());
+ if (process_sp)
{
- if (error.Success())
- return 0;
+ Error error;
+ if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
+ {
+ if (error.Success())
+ return 0;
+ }
}
return -1;
}
@@ -45,11 +49,15 @@ RegisterContextKDP_i386::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
int
RegisterContextKDP_i386::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
{
- Error error;
- if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
+ ProcessSP process_sp (CalculateProcess());
+ if (process_sp)
{
- if (error.Success())
- return 0;
+ Error error;
+ if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
+ {
+ if (error.Success())
+ return 0;
+ }
}
return -1;
}
@@ -57,11 +65,15 @@ RegisterContextKDP_i386::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
int
RegisterContextKDP_i386::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
{
- Error error;
- if (m_kdp_thread.GetKDPProcess().GetCommunication().SendRequestReadRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
+ ProcessSP process_sp (CalculateProcess());
+ if (process_sp)
{
- if (error.Success())
- return 0;
+ Error error;
+ if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
+ {
+ if (error.Success())
+ return 0;
+ }
}
return -1;
}
@@ -69,19 +81,19 @@ RegisterContextKDP_i386::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
int
RegisterContextKDP_i386::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
{
- return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
+ return -1;
}
int
RegisterContextKDP_i386::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
{
- return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
+ return -1;
}
int
RegisterContextKDP_i386::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
{
- return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
+ return -1;
}
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
index 6fb947087e5..9f68d104942 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
@@ -36,18 +36,18 @@ using namespace lldb_private;
// Thread Registers
//----------------------------------------------------------------------
-ThreadKDP::ThreadKDP (ProcessKDP &process, lldb::tid_t tid) :
- Thread(process, tid),
+ThreadKDP::ThreadKDP (const lldb::ProcessSP &process_sp, lldb::tid_t tid) :
+ Thread(process_sp, tid),
m_thread_name (),
m_dispatch_queue_name (),
m_thread_dispatch_qaddr (LLDB_INVALID_ADDRESS)
{
- ProcessKDPLog::LogIf(KDP_LOG_THREAD, "%p: ThreadKDP::ThreadKDP (pid = %i, tid = 0x%4.4x)", this, m_process.GetID(), GetID());
+ ProcessKDPLog::LogIf(KDP_LOG_THREAD, "%p: ThreadKDP::ThreadKDP (tid = 0x%4.4x)", this, GetID());
}
ThreadKDP::~ThreadKDP ()
{
- ProcessKDPLog::LogIf(KDP_LOG_THREAD, "%p: ThreadKDP::~ThreadKDP (pid = %i, tid = 0x%4.4x)", this, m_process.GetID(), GetID());
+ ProcessKDPLog::LogIf(KDP_LOG_THREAD, "%p: ThreadKDP::~ThreadKDP (tid = 0x%4.4x)", this, GetID());
DestroyThread();
}
@@ -157,20 +157,24 @@ ThreadKDP::CreateRegisterContextForFrame (StackFrame *frame)
if (concrete_frame_idx == 0)
{
- switch (GetKDPProcess().GetCommunication().GetCPUType())
+ ProcessSP process_sp (CalculateProcess());
+ if (process_sp)
{
- case llvm::MachO::CPUTypeARM:
- reg_ctx_sp.reset (new RegisterContextKDP_arm (*this, concrete_frame_idx));
- break;
- case llvm::MachO::CPUTypeI386:
- reg_ctx_sp.reset (new RegisterContextKDP_i386 (*this, concrete_frame_idx));
- break;
- case llvm::MachO::CPUTypeX86_64:
- reg_ctx_sp.reset (new RegisterContextKDP_x86_64 (*this, concrete_frame_idx));
- break;
- default:
- assert (!"Add CPU type support in KDP");
- break;
+ switch (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().GetCPUType())
+ {
+ case llvm::MachO::CPUTypeARM:
+ reg_ctx_sp.reset (new RegisterContextKDP_arm (*this, concrete_frame_idx));
+ break;
+ case llvm::MachO::CPUTypeI386:
+ reg_ctx_sp.reset (new RegisterContextKDP_i386 (*this, concrete_frame_idx));
+ break;
+ case llvm::MachO::CPUTypeX86_64:
+ reg_ctx_sp.reset (new RegisterContextKDP_x86_64 (*this, concrete_frame_idx));
+ break;
+ default:
+ assert (!"Add CPU type support in KDP");
+ break;
+ }
}
}
else if (m_unwinder_ap.get())
@@ -181,26 +185,30 @@ ThreadKDP::CreateRegisterContextForFrame (StackFrame *frame)
lldb::StopInfoSP
ThreadKDP::GetPrivateStopReason ()
{
- const uint32_t process_stop_id = GetProcess().GetStopID();
- if (m_thread_stop_reason_stop_id != process_stop_id ||
- (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
+ ProcessSP process_sp (GetProcess());
+ if (process_sp)
{
- // TODO: can we query the initial state of the thread here?
- // For now I am just going to pretend that a SIGSTOP happened.
-
- SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP));
-
- // If GetKDPProcess().SetThreadStopInfo() doesn't find a stop reason
- // for this thread, then m_actual_stop_info_sp will not ever contain
- // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
- // check will never be able to tell us if we have the correct stop info
- // for this thread and we will continually send qThreadStopInfo packets
- // down to the remote KDP server, so we need to keep our own notion
- // of the stop ID that m_actual_stop_info_sp is valid for (even if it
- // contains nothing). We use m_thread_stop_reason_stop_id for this below.
-// m_thread_stop_reason_stop_id = process_stop_id;
-// m_actual_stop_info_sp.reset();
+ const uint32_t process_stop_id = process_sp->GetStopID();
+ if (m_thread_stop_reason_stop_id != process_stop_id ||
+ (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
+ {
+ // TODO: can we query the initial state of the thread here?
+ // For now I am just going to pretend that a SIGSTOP happened.
+
+ SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP));
+
+ // If GetKDPProcess().SetThreadStopInfo() doesn't find a stop reason
+ // for this thread, then m_actual_stop_info_sp will not ever contain
+ // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
+ // check will never be able to tell us if we have the correct stop info
+ // for this thread and we will continually send qThreadStopInfo packets
+ // down to the remote KDP server, so we need to keep our own notion
+ // of the stop ID that m_actual_stop_info_sp is valid for (even if it
+ // contains nothing). We use m_thread_stop_reason_stop_id for this below.
+ // m_thread_stop_reason_stop_id = process_stop_id;
+ // m_actual_stop_info_sp.reset();
+ }
}
return m_actual_stop_info_sp;
}
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h
index a37fa91ee2b..1bf688de20a 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h
@@ -20,7 +20,7 @@ class ProcessKDP;
class ThreadKDP : public lldb_private::Thread
{
public:
- ThreadKDP (ProcessKDP &process,
+ ThreadKDP (const lldb::ProcessSP &process_sp,
lldb::tid_t tid);
virtual
@@ -47,12 +47,6 @@ public:
virtual void
ClearStackFrames ();
- ProcessKDP &
- GetKDPProcess ()
- {
- return (ProcessKDP &)m_process;
- }
-
void
Dump (lldb_private::Log *log, uint32_t index);
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 3ae19f9f511..1b230876307 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -85,7 +85,9 @@ RegisterContextLLDB::RegisterContextLLDB
void
RegisterContextLLDB::InitializeZerothFrame()
{
+ ExecutionContext exe_ctx(m_thread.shared_from_this());
StackFrameSP frame_sp (m_thread.GetStackFrameAtIndex (0));
+ exe_ctx.SetFrameSP (frame_sp);
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
@@ -158,7 +160,7 @@ RegisterContextLLDB::InitializeZerothFrame()
if (active_row && log)
{
StreamString active_row_strm;
- active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(), &m_thread, m_start_pc.GetLoadAddress(&m_thread.GetProcess().GetTarget()));
+ active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(), &m_thread, m_start_pc.GetLoadAddress(exe_ctx.GetTargetPtr()));
log->Printf("%*sFrame %u active row: %s",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, active_row_strm.GetString().c_str());
}
@@ -210,7 +212,7 @@ RegisterContextLLDB::InitializeZerothFrame()
m_frame_number < 100 ? m_frame_number : 100, "",
m_thread.GetIndexID(),
m_frame_number,
- (uint64_t) m_current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()),
+ (uint64_t) m_current_pc.GetLoadAddress (exe_ctx.GetTargetPtr()),
(uint64_t) m_cfa,
m_full_unwind_plan_sp->GetSourceName().GetCString());
}
@@ -274,13 +276,15 @@ RegisterContextLLDB::InitializeNonZerothFrame()
return;
}
+ ExecutionContext exe_ctx(m_thread.shared_from_this());
+ Process *process = exe_ctx.GetProcessPtr();
// Let ABIs fixup code addresses to make sure they are valid. In ARM ABIs
// this will strip bit zero in case we read a PC from memory or from the LR.
- ABI *abi = m_thread.GetProcess().GetABI().get();
+ ABI *abi = process->GetABI().get();
if (abi)
pc = abi->FixCodeAddress(pc);
- m_thread.GetProcess().GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, m_current_pc);
+ process->GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, m_current_pc);
// If we don't have a Module for some reason, we're not going to find symbol/function information - just
// stick in some reasonable defaults and hope we can unwind past this frame.
@@ -294,7 +298,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
// Test the pc value to see if we know it's in an unmapped/non-executable region of memory.
uint32_t permissions;
- if (m_thread.GetProcess().GetLoadAddressPermissions(pc, permissions)
+ if (process->GetLoadAddressPermissions(pc, permissions)
&& (permissions & ePermissionsExecutable) == 0)
{
// If this is the second frame off the stack, we may have unwound the first frame
@@ -366,7 +370,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
// cfa_regval should point into the stack memory; if we can query memory region permissions,
// see if the memory is allocated & readable.
- if (m_thread.GetProcess().GetLoadAddressPermissions(cfa_regval, permissions)
+ if (process->GetLoadAddressPermissions(cfa_regval, permissions)
&& (permissions & ePermissionsReadable) == 0)
{
m_frame_type = eNotAValidFrame;
@@ -495,7 +499,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
if (active_row && log)
{
StreamString active_row_strm;
- active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(), &m_thread, m_start_pc.GetLoadAddress(&m_thread.GetProcess().GetTarget()));
+ active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(), &m_thread, m_start_pc.GetLoadAddress(exe_ctx.GetTargetPtr()));
log->Printf("%*sFrame %u active row: %s",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, active_row_strm.GetString().c_str());
}
@@ -510,7 +514,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
if (active_row && log)
{
StreamString active_row_strm;
- active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(), &m_thread, m_start_pc.GetLoadAddress(&m_thread.GetProcess().GetTarget()));
+ active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(), &m_thread, m_start_pc.GetLoadAddress(exe_ctx.GetTargetPtr()));
log->Printf("%*sFrame %u active row: %s",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, active_row_strm.GetString().c_str());
}
@@ -594,7 +598,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
{
log->Printf("%*sFrame %u initialized frame current pc is 0x%llx cfa is 0x%llx",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
- (uint64_t) m_current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()), (uint64_t) m_cfa);
+ (uint64_t) m_current_pc.GetLoadAddress (exe_ctx.GetTargetPtr()), (uint64_t) m_cfa);
}
}
@@ -671,8 +675,9 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
UnwindPlanSP unwind_plan_sp;
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
UnwindPlanSP arch_default_unwind_plan_sp;
-
- ABI *abi = m_thread.GetProcess().GetABI().get();
+ ExecutionContext exe_ctx(m_thread.shared_from_this());
+ Process *process = exe_ctx.GetProcessPtr();
+ ABI *abi = process ? process->GetABI().get() : NULL;
if (abi)
{
arch_default_unwind_plan_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));
@@ -699,9 +704,9 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
if ((!m_sym_ctx_valid || m_sym_ctx.function == NULL) && behaves_like_zeroth_frame && m_current_pc.IsValid())
{
uint32_t permissions;
- addr_t current_pc_addr = m_current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget());
+ addr_t current_pc_addr = m_current_pc.GetLoadAddress (exe_ctx.GetTargetPtr());
if (current_pc_addr == 0
- || (m_thread.GetProcess().GetLoadAddressPermissions(current_pc_addr, permissions)
+ || (process->GetLoadAddressPermissions(current_pc_addr, permissions)
&& (permissions & ePermissionsExecutable) == 0))
{
unwind_plan_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric));
@@ -749,8 +754,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
// right thing. It'd be nice if there was a way to ask the eh_frame directly if it is asynchronous
// (can be trusted at every instruction point) or synchronous (the normal case - only at call sites).
// But there is not.
- if (m_thread.GetProcess().GetDynamicLoader()
- && m_thread.GetProcess().GetDynamicLoader()->AlwaysRelyOnEHUnwindInfo (m_sym_ctx))
+ if (process->GetDynamicLoader() && process->GetDynamicLoader()->AlwaysRelyOnEHUnwindInfo (m_sym_ctx))
{
unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one);
if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc))
@@ -1075,12 +1079,15 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, lldb_privat
}
}
}
-
+
+
+ ExecutionContext exe_ctx(m_thread.shared_from_this());
+ Process *process = exe_ctx.GetProcessPtr();
if (have_unwindplan_regloc == false)
{
// If a volatile register is being requested, we don't want to forward the next frame's register contents
// up the stack -- the register is not retrievable at this frame.
- ABI *abi = m_thread.GetProcess().GetABI().get();
+ ABI *abi = process ? process->GetABI().get() : NULL;
if (abi)
{
const RegisterInfo *reg_info = GetRegisterInfoAtIndex(lldb_regnum);
@@ -1198,10 +1205,9 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, lldb_privat
{
DataExtractor dwarfdata (unwindplan_regloc.GetDWARFExpressionBytes(),
unwindplan_regloc.GetDWARFExpressionLength(),
- m_thread.GetProcess().GetByteOrder(), m_thread.GetProcess().GetAddressByteSize());
+ process->GetByteOrder(), process->GetAddressByteSize());
DWARFExpression dwarfexpr (dwarfdata, 0, unwindplan_regloc.GetDWARFExpressionLength());
dwarfexpr.SetRegisterKind (unwindplan_registerkind);
- ExecutionContext exe_ctx (&m_thread.GetProcess(), &m_thread, NULL);
Value result;
Error error;
if (dwarfexpr.Evaluate (&exe_ctx, NULL, NULL, NULL, this, 0, NULL, result, &error))
@@ -1432,7 +1438,7 @@ RegisterContextLLDB::GetStartPC (addr_t& start_pc)
{
return ReadPC (start_pc);
}
- start_pc = m_start_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget());
+ start_pc = m_start_pc.GetLoadAddress (CalculateTarget().get());
return true;
}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp
index ff077b4d640..03610a2fe7c 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp
@@ -134,11 +134,15 @@ RegisterContextMemory::ReadAllRegisterValues (DataBufferSP &data_sp)
{
if (m_reg_data_addr != LLDB_INVALID_ADDRESS)
{
- Error error;
- if (m_thread.GetProcess().ReadMemory(m_reg_data_addr, data_sp->GetBytes(), data_sp->GetByteSize(), error) == data_sp->GetByteSize())
+ ProcessSP process_sp (CalculateProcess());
+ if (process_sp)
{
- SetAllRegisterValid (true);
- return true;
+ Error error;
+ if (process_sp->ReadMemory(m_reg_data_addr, data_sp->GetBytes(), data_sp->GetByteSize(), error) == data_sp->GetByteSize())
+ {
+ SetAllRegisterValid (true);
+ return true;
+ }
}
}
return false;
@@ -149,10 +153,14 @@ RegisterContextMemory::WriteAllRegisterValues (const DataBufferSP &data_sp)
{
if (m_reg_data_addr != LLDB_INVALID_ADDRESS)
{
- Error error;
- SetAllRegisterValid (false);
- if (m_thread.GetProcess().WriteMemory(m_reg_data_addr, data_sp->GetBytes(), data_sp->GetByteSize(), error) == data_sp->GetByteSize())
- return true;
+ ProcessSP process_sp (CalculateProcess());
+ if (process_sp)
+ {
+ Error error;
+ SetAllRegisterValid (false);
+ if (process_sp->WriteMemory(m_reg_data_addr, data_sp->GetBytes(), data_sp->GetByteSize(), error) == data_sp->GetByteSize())
+ return true;
+ }
}
return false;
}
diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 8915dd789bb..95f3633616c 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -16,6 +16,7 @@
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
@@ -31,7 +32,9 @@ StopInfoMachException::GetDescription ()
{
if (m_description.empty() && m_value != 0)
{
- const llvm::Triple::ArchType cpu = m_thread.GetProcess().GetTarget().GetArchitecture().GetMachine();
+ ExecutionContext exe_ctx (m_thread.shared_from_this());
+ Target *target = exe_ctx.GetTargetPtr();
+ const llvm::Triple::ArchType cpu = target ? target->GetArchitecture().GetMachine() : llvm::Triple::InvalidArch;
const char *exc_desc = NULL;
const char *code_label = "code";
@@ -252,7 +255,9 @@ StopInfoMachException::CreateStopReasonWithMachException
{
if (exc_type != 0)
{
- const llvm::Triple::ArchType cpu = thread.GetProcess().GetTarget().GetArchitecture().GetMachine();
+ ExecutionContext exe_ctx (thread.shared_from_this());
+ Target *target = exe_ctx.GetTargetPtr();
+ const llvm::Triple::ArchType cpu = target ? target->GetArchitecture().GetMachine() : llvm::Triple::InvalidArch;
switch (exc_type)
{
@@ -306,8 +311,9 @@ StopInfoMachException::CreateStopReasonWithMachException
// It's a watchpoint, then.
// The exc_sub_code indicates the data break address.
- lldb::WatchpointSP wp_sp =
- thread.GetProcess().GetTarget().GetWatchpointList().FindByAddress((lldb::addr_t)exc_sub_code);
+ lldb::WatchpointSP wp_sp;
+ if (target)
+ wp_sp = target->GetWatchpointList().FindByAddress((lldb::addr_t)exc_sub_code);
if (wp_sp)
{
// Debugserver may piggyback the hardware index of the fired watchpoint in the exception data.
@@ -345,7 +351,11 @@ StopInfoMachException::CreateStopReasonWithMachException
if (is_software_breakpoint)
{
addr_t pc = thread.GetRegisterContext()->GetPC();
- lldb::BreakpointSiteSP bp_site_sp = thread.GetProcess().GetBreakpointSiteList().FindByAddress(pc);
+ ProcessSP process_sp (thread.CalculateProcess());
+
+ lldb::BreakpointSiteSP bp_site_sp;
+ if (process_sp)
+ bp_site_sp = process_sp->GetBreakpointSiteList().FindByAddress(pc);
if (bp_site_sp)
{
// If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
index 95f05fd8bd6..dfcc2b04f24 100644
--- a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
@@ -17,10 +17,10 @@
using namespace lldb;
using namespace lldb_private;
-ThreadMemory::ThreadMemory (Process &process,
+ThreadMemory::ThreadMemory (const ProcessSP &process_sp,
tid_t tid,
const ValueObjectSP &thread_info_valobj_sp) :
- Thread (process, tid),
+ Thread (process_sp, tid),
m_thread_info_valobj_sp (thread_info_valobj_sp)
{
}
@@ -47,9 +47,13 @@ ThreadMemory::GetRegisterContext ()
{
if (!m_reg_context_sp)
{
- OperatingSystem *os = m_process.GetOperatingSystem ();
- if (os)
- m_reg_context_sp = os->CreateRegisterContextForThread (this);
+ ProcessSP process_sp (GetProcess());
+ if (process_sp)
+ {
+ OperatingSystem *os = process_sp->GetOperatingSystem ();
+ if (os)
+ m_reg_context_sp = os->CreateRegisterContextForThread (this);
+ }
}
return m_reg_context_sp;
}
@@ -77,24 +81,29 @@ ThreadMemory::CreateRegisterContextForFrame (StackFrame *frame)
lldb::StopInfoSP
ThreadMemory::GetPrivateStopReason ()
{
- const uint32_t process_stop_id = GetProcess().GetStopID();
- if (m_thread_stop_reason_stop_id != process_stop_id ||
- (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
+ ProcessSP process_sp (GetProcess());
+
+ if (process_sp)
{
- // If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason
- // for this thread, then m_actual_stop_info_sp will not ever contain
- // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
- // check will never be able to tell us if we have the correct stop info
- // for this thread and we will continually send qThreadStopInfo packets
- // down to the remote GDB server, so we need to keep our own notion
- // of the stop ID that m_actual_stop_info_sp is valid for (even if it
- // contains nothing). We use m_thread_stop_reason_stop_id for this below.
- m_thread_stop_reason_stop_id = process_stop_id;
- m_actual_stop_info_sp.reset();
-
- OperatingSystem *os = m_process.GetOperatingSystem ();
- if (os)
- m_actual_stop_info_sp = os->CreateThreadStopReason (this);
+ const uint32_t process_stop_id = process_sp->GetStopID();
+ if (m_thread_stop_reason_stop_id != process_stop_id ||
+ (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
+ {
+ // If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason
+ // for this thread, then m_actual_stop_info_sp will not ever contain
+ // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
+ // check will never be able to tell us if we have the correct stop info
+ // for this thread and we will continually send qThreadStopInfo packets
+ // down to the remote GDB server, so we need to keep our own notion
+ // of the stop ID that m_actual_stop_info_sp is valid for (even if it
+ // contains nothing). We use m_thread_stop_reason_stop_id for this below.
+ m_thread_stop_reason_stop_id = process_stop_id;
+ m_actual_stop_info_sp.reset();
+
+ OperatingSystem *os = process_sp->GetOperatingSystem ();
+ if (os)
+ m_actual_stop_info_sp = os->CreateThreadStopReason (this);
+ }
}
return m_actual_stop_info_sp;
diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.h b/lldb/source/Plugins/Process/Utility/ThreadMemory.h
index 93cc255a128..96b40a08143 100644
--- a/lldb/source/Plugins/Process/Utility/ThreadMemory.h
+++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.h
@@ -17,9 +17,9 @@ class ThreadMemory :
{
public:
- ThreadMemory (lldb_private::Process &process,
- lldb::tid_t tid,
- const lldb::ValueObjectSP &thread_info_valobj_sp);
+ ThreadMemory (const lldb::ProcessSP &process_sp,
+ lldb::tid_t tid,
+ const lldb::ValueObjectSP &thread_info_valobj_sp);
virtual
~ThreadMemory();
diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp
index bf71b008bd5..1ba3f0f419f 100644
--- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp
+++ b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp
@@ -42,7 +42,8 @@ UnwindLLDB::DoGetFrameCount()
if (!AddFirstFrame ())
return 0;
- ABI *abi = m_thread.GetProcess().GetABI().get();
+ ProcessSP process_sp (m_thread.GetProcess());
+ ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
while (AddOneMoreFrame (abi))
{
@@ -186,7 +187,8 @@ UnwindLLDB::DoGetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr_t& pc)
return false;
}
- ABI *abi = m_thread.GetProcess().GetABI().get();
+ ProcessSP process_sp (m_thread.GetProcess());
+ ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
while (idx >= m_frames.size() && AddOneMoreFrame (abi))
;
@@ -217,7 +219,8 @@ UnwindLLDB::DoCreateRegisterContextForFrame (StackFrame *frame)
return reg_ctx_sp;
}
- ABI *abi = m_thread.GetProcess().GetABI().get();
+ ProcessSP process_sp (m_thread.GetProcess());
+ ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
while (idx >= m_frames.size())
{
diff --git a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp b/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
index 5706c6d2381..f1cb91535eb 100644
--- a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
+++ b/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
@@ -12,9 +12,10 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
#include "RegisterContextMacOSXFrameBackchain.h"
@@ -32,14 +33,19 @@ UnwindMacOSXFrameBackchain::DoGetFrameCount()
{
if (m_cursors.empty())
{
- const ArchSpec& target_arch = m_thread.GetProcess().GetTarget().GetArchitecture ();
- // Frame zero should always be supplied by the thread...
- StackFrameSP frame_sp (m_thread.GetStackFrameAtIndex (0));
-
- if (target_arch.GetAddressByteSize() == 8)
- GetStackFrameData_x86_64 (frame_sp.get());
- else
- GetStackFrameData_i386 (frame_sp.get());
+ ExecutionContext exe_ctx (m_thread.shared_from_this());
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target)
+ {
+ const ArchSpec& target_arch = target->GetArchitecture ();
+ // Frame zero should always be supplied by the thread...
+ exe_ctx.SetFrameSP (m_thread.GetStackFrameAtIndex (0));
+
+ if (target_arch.GetAddressByteSize() == 8)
+ GetStackFrameData_x86_64 (exe_ctx);
+ else
+ GetStackFrameData_i386 (exe_ctx);
+ }
}
return m_cursors.size();
}
@@ -75,10 +81,16 @@ UnwindMacOSXFrameBackchain::DoCreateRegisterContextForFrame (StackFrame *frame)
}
size_t
-UnwindMacOSXFrameBackchain::GetStackFrameData_i386 (StackFrame *first_frame)
+UnwindMacOSXFrameBackchain::GetStackFrameData_i386 (const ExecutionContext &exe_ctx)
{
m_cursors.clear();
+
+ StackFrame *first_frame = exe_ctx.GetFramePtr();
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process == NULL)
+ return 0;
+
std::pair<lldb::addr_t, lldb::addr_t> fp_pc_pair;
struct Frame_i386
@@ -103,7 +115,7 @@ UnwindMacOSXFrameBackchain::GetStackFrameData_i386 (StackFrame *first_frame)
while (frame.fp != 0 && frame.pc != 0 && ((frame.fp & 7) == 0))
{
// Read both the FP and PC (8 bytes)
- if (m_thread.GetProcess().ReadMemory (frame.fp, &frame.fp, k_frame_size, error) != k_frame_size)
+ if (process->ReadMemory (frame.fp, &frame.fp, k_frame_size, error) != k_frame_size)
break;
if (frame.pc >= 0x1000)
{
@@ -137,7 +149,7 @@ UnwindMacOSXFrameBackchain::GetStackFrameData_i386 (StackFrame *first_frame)
// previous PC by dereferencing the SP
lldb::addr_t first_frame_sp = reg_ctx->GetSP (0);
// Read the real second frame return address into frame.pc
- if (first_frame_sp && m_thread.GetProcess().ReadMemory (first_frame_sp, &frame.pc, sizeof(frame.pc), error) == sizeof(frame.pc))
+ if (first_frame_sp && process->ReadMemory (first_frame_sp, &frame.pc, sizeof(frame.pc), error) == sizeof(frame.pc))
{
cursor.fp = m_cursors.front().fp;
cursor.pc = frame.pc; // Set the new second frame PC
@@ -163,10 +175,16 @@ UnwindMacOSXFrameBackchain::GetStackFrameData_i386 (StackFrame *first_frame)
size_t
-UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64 (StackFrame *first_frame)
+UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64 (const ExecutionContext &exe_ctx)
{
m_cursors.clear();
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process == NULL)
+ return 0;
+
+ StackFrame *first_frame = exe_ctx.GetFramePtr();
+
std::pair<lldb::addr_t, lldb::addr_t> fp_pc_pair;
struct Frame_x86_64
@@ -190,7 +208,7 @@ UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64 (StackFrame *first_frame)
while (frame.fp != 0 && frame.pc != 0 && ((frame.fp & 7) == 0))
{
// Read both the FP and PC (16 bytes)
- if (m_thread.GetProcess().ReadMemory (frame.fp, &frame.fp, k_frame_size, error) != k_frame_size)
+ if (process->ReadMemory (frame.fp, &frame.fp, k_frame_size, error) != k_frame_size)
break;
if (frame.pc >= 0x1000)
@@ -225,7 +243,7 @@ UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64 (StackFrame *first_frame)
// previous PC by dereferencing the SP
lldb::addr_t first_frame_sp = reg_ctx->GetSP (0);
// Read the real second frame return address into frame.pc
- if (m_thread.GetProcess().ReadMemory (first_frame_sp, &frame.pc, sizeof(frame.pc), error) == sizeof(frame.pc))
+ if (process->ReadMemory (first_frame_sp, &frame.pc, sizeof(frame.pc), error) == sizeof(frame.pc))
{
cursor.fp = m_cursors.front().fp;
cursor.pc = frame.pc; // Set the new second frame PC
diff --git a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h b/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
index 5667aaf7462..2695376fd6e 100644
--- a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
+++ b/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
@@ -60,10 +60,10 @@ private:
std::vector<Cursor> m_cursors;
size_t
- GetStackFrameData_i386 (lldb_private::StackFrame *first_frame);
+ GetStackFrameData_i386 (const lldb_private::ExecutionContext &exe_ctx);
size_t
- GetStackFrameData_x86_64 (lldb_private::StackFrame *first_frame);
+ GetStackFrameData_x86_64 (const lldb_private::ExecutionContext &exe_ctx);
//------------------------------------------------------------------
// For UnwindMacOSXFrameBackchain only
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 07b17b4edd7..06488451736 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Target/ExecutionContext.h"
// Project includes
#include "Utility/StringExtractorGDBRemote.h"
#include "ProcessGDBRemote.h"
@@ -61,18 +62,6 @@ GDBRemoteRegisterContext::~GDBRemoteRegisterContext()
{
}
-ProcessGDBRemote &
-GDBRemoteRegisterContext::GetGDBProcess()
-{
- return static_cast<ProcessGDBRemote &>(m_thread.GetProcess());
-}
-
-ThreadGDBRemote &
-GDBRemoteRegisterContext::GetGDBThread()
-{
- return static_cast<ThreadGDBRemote &>(m_thread);
-}
-
void
GDBRemoteRegisterContext::InvalidateAllRegisters ()
{
@@ -158,7 +147,14 @@ GDBRemoteRegisterContext::PrivateSetRegisterValue (uint32_t reg, StringExtractor
bool
GDBRemoteRegisterContext::ReadRegisterBytes (const RegisterInfo *reg_info, DataExtractor &data)
{
- GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote());
+ ExecutionContext exe_ctx (CalculateThread());
+
+ Process *process = exe_ctx.GetProcessPtr();
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (process == NULL || thread == NULL)
+ return false;
+
+ GDBRemoteCommunicationClient &gdb_comm (((ProcessGDBRemote *)process)->GetGDBRemote());
InvalidateIfNeeded(false);
@@ -170,7 +166,8 @@ GDBRemoteRegisterContext::ReadRegisterBytes (const RegisterInfo *reg_info, DataE
if (gdb_comm.GetSequenceMutex (locker))
{
const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported();
- if (thread_suffix_supported || GetGDBProcess().GetGDBRemote().SetCurrentThread(m_thread.GetID()))
+ ProcessSP process_sp (m_thread.GetProcess());
+ if (thread_suffix_supported || static_cast<ProcessGDBRemote *>(process_sp.get())->GetGDBRemote().SetCurrentThread(m_thread.GetID()))
{
char packet[64];
StringExtractorGDBRemote response;
@@ -238,7 +235,14 @@ GDBRemoteRegisterContext::WriteRegister (const RegisterInfo *reg_info,
bool
GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info, DataExtractor &data, uint32_t data_offset)
{
- GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote());
+ ExecutionContext exe_ctx (CalculateThread());
+
+ Process *process = exe_ctx.GetProcessPtr();
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (process == NULL || thread == NULL)
+ return false;
+
+ GDBRemoteCommunicationClient &gdb_comm (((ProcessGDBRemote *)process)->GetGDBRemote());
// FIXME: This check isn't right because IsRunning checks the Public state, but this
// is work you need to do - for instance in ShouldStop & friends - before the public
// state has been changed.
@@ -264,7 +268,8 @@ GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo *
if (gdb_comm.GetSequenceMutex (locker))
{
const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported();
- if (thread_suffix_supported || GetGDBProcess().GetGDBRemote().SetCurrentThread(m_thread.GetID()))
+ ProcessSP process_sp (m_thread.GetProcess());
+ if (thread_suffix_supported || static_cast<ProcessGDBRemote *>(process_sp.get())->GetGDBRemote().SetCurrentThread(m_thread.GetID()))
{
uint32_t offset, end_offset;
StreamString packet;
@@ -334,7 +339,15 @@ GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo *
bool
GDBRemoteRegisterContext::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
{
- GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote());
+ ExecutionContext exe_ctx (CalculateThread());
+
+ Process *process = exe_ctx.GetProcessPtr();
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (process == NULL || thread == NULL)
+ return false;
+
+ GDBRemoteCommunicationClient &gdb_comm (((ProcessGDBRemote *)process)->GetGDBRemote());
+
StringExtractorGDBRemote response;
Mutex::Locker locker;
@@ -342,7 +355,8 @@ GDBRemoteRegisterContext::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
{
char packet[32];
const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported();
- if (thread_suffix_supported || GetGDBProcess().GetGDBRemote().SetCurrentThread(m_thread.GetID()))
+ ProcessSP process_sp (m_thread.GetProcess());
+ if (thread_suffix_supported || static_cast<ProcessGDBRemote *>(process_sp.get())->GetGDBRemote().SetCurrentThread(m_thread.GetID()))
{
int packet_len = 0;
if (thread_suffix_supported)
@@ -382,13 +396,22 @@ GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data
if (!data_sp || data_sp->GetBytes() == NULL || data_sp->GetByteSize() == 0)
return false;
- GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote());
+ ExecutionContext exe_ctx (CalculateThread());
+
+ Process *process = exe_ctx.GetProcessPtr();
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (process == NULL || thread == NULL)
+ return false;
+
+ GDBRemoteCommunicationClient &gdb_comm (((ProcessGDBRemote *)process)->GetGDBRemote());
+
StringExtractorGDBRemote response;
Mutex::Locker locker;
if (gdb_comm.GetSequenceMutex (locker))
{
const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported();
- if (thread_suffix_supported || GetGDBProcess().GetGDBRemote().SetCurrentThread(m_thread.GetID()))
+ ProcessSP process_sp (m_thread.GetProcess());
+ if (thread_suffix_supported || static_cast<ProcessGDBRemote *>(process_sp.get())->GetGDBRemote().SetCurrentThread(m_thread.GetID()))
{
// The data_sp contains the entire G response packet including the
// G, and if the thread suffix is supported, it has the thread suffix
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
index d1955e84130..9f96e77cb54 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -240,12 +240,6 @@ protected:
void
SetAllRegisterValid (bool b);
- ProcessGDBRemote &
- GetGDBProcess();
-
- ThreadGDBRemote &
- GetGDBThread();
-
GDBRemoteDynamicRegisterInfo &m_reg_info;
std::vector<bool> m_reg_valid;
lldb_private::DataExtractor m_reg_data;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 8424d2a32be..53b7a24d2e8 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1125,7 +1125,7 @@ ProcessGDBRemote::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new
tid_t tid = thread_ids[i];
ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false));
if (!thread_sp)
- thread_sp.reset (new ThreadGDBRemote (*this, tid));
+ thread_sp.reset (new ThreadGDBRemote (shared_from_this(), tid));
new_thread_list.AddThread(thread_sp);
}
}
@@ -1201,7 +1201,7 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
if (!thread_sp)
{
// Create the thread if we need to
- thread_sp.reset (new ThreadGDBRemote (*this, tid));
+ thread_sp.reset (new ThreadGDBRemote (shared_from_this(), tid));
m_thread_list.AddThread(thread_sp);
}
}
@@ -1292,7 +1292,7 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
else if (reason.compare("breakpoint") == 0)
{
addr_t pc = gdb_thread->GetRegisterContext()->GetPC();
- lldb::BreakpointSiteSP bp_site_sp = gdb_thread->GetProcess().GetBreakpointSiteList().FindByAddress(pc);
+ lldb::BreakpointSiteSP bp_site_sp = gdb_thread->GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
if (bp_site_sp)
{
// If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
@@ -1335,7 +1335,7 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
// Currently we are going to assume SIGTRAP means we are either
// hitting a breakpoint or hardware single stepping.
addr_t pc = gdb_thread->GetRegisterContext()->GetPC();
- lldb::BreakpointSiteSP bp_site_sp = gdb_thread->GetProcess().GetBreakpointSiteList().FindByAddress(pc);
+ lldb::BreakpointSiteSP bp_site_sp = gdb_thread->GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
if (bp_site_sp)
{
// If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 49385916ad6..55cb222ce47 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -32,18 +32,25 @@ using namespace lldb_private;
// Thread Registers
//----------------------------------------------------------------------
-ThreadGDBRemote::ThreadGDBRemote (ProcessGDBRemote &process, lldb::tid_t tid) :
- Thread(process, tid),
+ThreadGDBRemote::ThreadGDBRemote (const ProcessSP &process_sp, lldb::tid_t tid) :
+ Thread(process_sp, tid),
m_thread_name (),
m_dispatch_queue_name (),
m_thread_dispatch_qaddr (LLDB_INVALID_ADDRESS)
{
- ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD, "%p: ThreadGDBRemote::ThreadGDBRemote (pid = %i, tid = 0x%4.4x)", this, m_process.GetID(), GetID());
+ ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD, "%p: ThreadGDBRemote::ThreadGDBRemote (pid = %i, tid = 0x%4.4x)",
+ this,
+ process_sp ? process_sp->GetID() : LLDB_INVALID_PROCESS_ID,
+ GetID());
}
ThreadGDBRemote::~ThreadGDBRemote ()
{
- ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD, "%p: ThreadGDBRemote::~ThreadGDBRemote (pid = %i, tid = 0x%4.4x)", this, m_process.GetID(), GetID());
+ ProcessSP process_sp(GetProcess());
+ ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD, "%p: ThreadGDBRemote::~ThreadGDBRemote (pid = %i, tid = 0x%4.4x)",
+ this,
+ process_sp ? process_sp->GetID() : LLDB_INVALID_PROCESS_ID,
+ GetID());
DestroyThread();
}
@@ -60,8 +67,16 @@ const char *
ThreadGDBRemote::GetQueueName ()
{
// Always re-fetch the dispatch queue name since it can change
+
if (m_thread_dispatch_qaddr != 0 || m_thread_dispatch_qaddr != LLDB_INVALID_ADDRESS)
- return GetGDBProcess().GetDispatchQueueNameForThread (m_thread_dispatch_qaddr, m_dispatch_queue_name);
+ {
+ ProcessSP process_sp (GetProcess());
+ if (process_sp)
+ {
+ ProcessGDBRemote *gdb_process = static_cast<ProcessGDBRemote *>(process_sp.get());
+ return gdb_process->GetDispatchQueueNameForThread (m_thread_dispatch_qaddr, m_dispatch_queue_name);
+ }
+ }
return NULL;
}
@@ -79,32 +94,37 @@ ThreadGDBRemote::WillResume (StateType resume_state)
if (log)
log->Printf ("Resuming thread: %4.4llx with state: %s.", GetID(), StateAsCString(resume_state));
- ProcessGDBRemote &process = GetGDBProcess();
- switch (resume_state)
+ ProcessSP process_sp (GetProcess());
+ if (process_sp)
{
- case eStateSuspended:
- case eStateStopped:
- // Don't append anything for threads that should stay stopped.
- break;
-
- case eStateRunning:
- if (m_process.GetUnixSignals().SignalIsValid (signo))
- process.m_continue_C_tids.push_back(std::make_pair(GetID(), signo));
- else
- process.m_continue_c_tids.push_back(GetID());
- break;
-
- case eStateStepping:
- if (m_process.GetUnixSignals().SignalIsValid (signo))
- process.m_continue_S_tids.push_back(std::make_pair(GetID(), signo));
- else
- process.m_continue_s_tids.push_back(GetID());
- break;
-
- default:
- break;
+ ProcessGDBRemote *gdb_process = static_cast<ProcessGDBRemote *>(process_sp.get());
+ switch (resume_state)
+ {
+ case eStateSuspended:
+ case eStateStopped:
+ // Don't append anything for threads that should stay stopped.
+ break;
+
+ case eStateRunning:
+ if (gdb_process->GetUnixSignals().SignalIsValid (signo))
+ gdb_process->m_continue_C_tids.push_back(std::make_pair(GetID(), signo));
+ else
+ gdb_process->m_continue_c_tids.push_back(GetID());
+ break;
+
+ case eStateStepping:
+ if (gdb_process->GetUnixSignals().SignalIsValid (signo))
+ gdb_process->m_continue_S_tids.push_back(std::make_pair(GetID(), signo));
+ else
+ gdb_process->m_continue_s_tids.push_back(GetID());
+ break;
+
+ default:
+ break;
+ }
+ return true;
}
- return true;
+ return false;
}
void
@@ -167,8 +187,16 @@ ThreadGDBRemote::CreateRegisterContextForFrame (StackFrame *frame)
if (frame)
concrete_frame_idx = frame->GetConcreteFrameIndex ();
+
if (concrete_frame_idx == 0)
- reg_ctx_sp.reset (new GDBRemoteRegisterContext (*this, concrete_frame_idx, GetGDBProcess().m_register_info, read_all_registers_at_once));
+ {
+ ProcessSP process_sp (GetProcess());
+ if (process_sp)
+ {
+ ProcessGDBRemote *gdb_process = static_cast<ProcessGDBRemote *>(process_sp.get());
+ reg_ctx_sp.reset (new GDBRemoteRegisterContext (*this, concrete_frame_idx, gdb_process->m_register_info, read_all_registers_at_once));
+ }
+ }
else if (m_unwinder_ap.get())
reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame (frame);
return reg_ctx_sp;
@@ -185,25 +213,29 @@ ThreadGDBRemote::PrivateSetRegisterValue (uint32_t reg, StringExtractor &respons
lldb::StopInfoSP
ThreadGDBRemote::GetPrivateStopReason ()
{
- const uint32_t process_stop_id = GetProcess().GetStopID();
- if (m_thread_stop_reason_stop_id != process_stop_id ||
- (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
+ ProcessSP process_sp (GetProcess());
+ if (process_sp)
{
- // If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason
- // for this thread, then m_actual_stop_info_sp will not ever contain
- // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
- // check will never be able to tell us if we have the correct stop info
- // for this thread and we will continually send qThreadStopInfo packets
- // down to the remote GDB server, so we need to keep our own notion
- // of the stop ID that m_actual_stop_info_sp is valid for (even if it
- // contains nothing). We use m_thread_stop_reason_stop_id for this below.
- m_thread_stop_reason_stop_id = process_stop_id;
- m_actual_stop_info_sp.reset();
-
- StringExtractorGDBRemote stop_packet;
- ProcessGDBRemote &gdb_process = GetGDBProcess();
- if (gdb_process.GetGDBRemote().GetThreadStopInfo(GetID(), stop_packet))
- gdb_process.SetThreadStopInfo (stop_packet);
+ const uint32_t process_stop_id = process_sp->GetStopID();
+ if (m_thread_stop_reason_stop_id != process_stop_id ||
+ (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
+ {
+ // If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason
+ // for this thread, then m_actual_stop_info_sp will not ever contain
+ // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
+ // check will never be able to tell us if we have the correct stop info
+ // for this thread and we will continually send qThreadStopInfo packets
+ // down to the remote GDB server, so we need to keep our own notion
+ // of the stop ID that m_actual_stop_info_sp is valid for (even if it
+ // contains nothing). We use m_thread_stop_reason_stop_id for this below.
+ m_thread_stop_reason_stop_id = process_stop_id;
+ m_actual_stop_info_sp.reset();
+
+ StringExtractorGDBRemote stop_packet;
+ ProcessGDBRemote *gdb_process = static_cast<ProcessGDBRemote *>(process_sp.get());
+ if (gdb_process->GetGDBRemote().GetThreadStopInfo(GetID(), stop_packet))
+ gdb_process->SetThreadStopInfo (stop_packet);
+ }
}
return m_actual_stop_info_sp;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
index 09f86845263..3eb6295f1f4 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
@@ -21,7 +21,7 @@ class ProcessGDBRemote;
class ThreadGDBRemote : public lldb_private::Thread
{
public:
- ThreadGDBRemote (ProcessGDBRemote &process, lldb::tid_t tid);
+ ThreadGDBRemote (const lldb::ProcessSP &process_sp, lldb::tid_t tid);
virtual
~ThreadGDBRemote ();
@@ -47,18 +47,6 @@ public:
virtual void
ClearStackFrames ();
- ProcessGDBRemote &
- GetGDBProcess ()
- {
- return (ProcessGDBRemote &)m_process;
- }
-
- const ProcessGDBRemote &
- GetGDBProcess () const
- {
- return (ProcessGDBRemote &)m_process;
- }
-
void
Dump (lldb_private::Log *log, uint32_t index);
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index 0dff8fd8572..8cd5b1b5728 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -354,7 +354,7 @@ ProcessMachCore::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_
const uint32_t num_threads = core_objfile->GetNumThreadContexts ();
for (lldb::tid_t tid = 0; tid < num_threads; ++tid)
{
- ThreadSP thread_sp(new ThreadMachCore (*this, tid));
+ ThreadSP thread_sp(new ThreadMachCore (shared_from_this(), tid));
new_thread_list.AddThread (thread_sp);
}
}
diff --git a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
index 7944996ff6f..c0eefe125b1 100644
--- a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
@@ -35,11 +35,12 @@ using namespace lldb_private;
// Thread Registers
//----------------------------------------------------------------------
-ThreadMachCore::ThreadMachCore (ProcessMachCore &process, lldb::tid_t tid) :
- Thread(process, tid),
+ThreadMachCore::ThreadMachCore (const lldb::ProcessSP &process_sp, lldb::tid_t tid) :
+ Thread(process_sp, tid),
m_thread_name (),
m_dispatch_queue_name (),
- m_thread_dispatch_qaddr (LLDB_INVALID_ADDRESS)
+ m_thread_dispatch_qaddr (LLDB_INVALID_ADDRESS),
+ m_thread_reg_ctx_sp ()
{
}
@@ -106,38 +107,51 @@ ThreadMachCore::CreateRegisterContextForFrame (StackFrame *frame)
if (concrete_frame_idx == 0)
{
- ObjectFile *core_objfile = GetMachCoreProcess ().GetCoreObjectFile ();
- if (core_objfile)
- reg_ctx_sp = core_objfile->GetThreadContextAtIndex (GetID(), *this);
+ if (!m_thread_reg_ctx_sp)
+ {
+ ProcessSP process_sp (GetProcess());
+
+ ObjectFile *core_objfile = static_cast<ProcessMachCore *>(process_sp.get())->GetCoreObjectFile ();
+ if (core_objfile)
+ m_thread_reg_ctx_sp = core_objfile->GetThreadContextAtIndex (GetID(), *this);
+ }
+ reg_ctx_sp = m_thread_reg_ctx_sp;
}
else if (m_unwinder_ap.get())
+ {
reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame (frame);
+ }
return reg_ctx_sp;
}
lldb::StopInfoSP
ThreadMachCore::GetPrivateStopReason ()
{
- const uint32_t process_stop_id = GetProcess().GetStopID();
- if (m_thread_stop_reason_stop_id != process_stop_id ||
- (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
- {
- // TODO: can we query the initial state of the thread here?
- // For now I am just going to pretend that a SIGSTOP happened.
-
- SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP));
-
- // If GetKDPProcess().SetThreadStopInfo() doesn't find a stop reason
- // for this thread, then m_actual_stop_info_sp will not ever contain
- // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
- // check will never be able to tell us if we have the correct stop info
- // for this thread and we will continually send qThreadStopInfo packets
- // down to the remote KDP server, so we need to keep our own notion
- // of the stop ID that m_actual_stop_info_sp is valid for (even if it
- // contains nothing). We use m_thread_stop_reason_stop_id for this below.
-// m_thread_stop_reason_stop_id = process_stop_id;
-// m_actual_stop_info_sp.reset();
+ ProcessSP process_sp (GetProcess());
+ if (process_sp)
+ {
+ const uint32_t process_stop_id = process_sp->GetStopID();
+ if (m_thread_stop_reason_stop_id != process_stop_id ||
+ (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
+ {
+ // TODO: can we query the initial state of the thread here?
+ // For now I am just going to pretend that a SIGSTOP happened.
+
+ SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP));
+
+ // If GetKDPProcess().SetThreadStopInfo() doesn't find a stop reason
+ // for this thread, then m_actual_stop_info_sp will not ever contain
+ // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
+ // check will never be able to tell us if we have the correct stop info
+ // for this thread and we will continually send qThreadStopInfo packets
+ // down to the remote KDP server, so we need to keep our own notion
+ // of the stop ID that m_actual_stop_info_sp is valid for (even if it
+ // contains nothing). We use m_thread_stop_reason_stop_id for this below.
+ // m_thread_stop_reason_stop_id = process_stop_id;
+ // m_actual_stop_info_sp.reset();
+
+ }
}
return m_actual_stop_info_sp;
}
diff --git a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
index dbfae485057..497620cdb0f 100644
--- a/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
+++ b/lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
@@ -19,7 +19,7 @@ class ProcessMachCore;
class ThreadMachCore : public lldb_private::Thread
{
public:
- ThreadMachCore (ProcessMachCore &process,
+ ThreadMachCore (const lldb::ProcessSP &process_sp,
lldb::tid_t tid);
virtual
@@ -40,12 +40,6 @@ public:
virtual void
ClearStackFrames ();
- ProcessMachCore &
- GetMachCoreProcess ()
- {
- return (ProcessMachCore &)m_process;
- }
-
static bool
ThreadIDIsValid (lldb::tid_t thread);
@@ -86,6 +80,7 @@ protected:
std::string m_thread_name;
std::string m_dispatch_queue_name;
lldb::addr_t m_thread_dispatch_qaddr;
+ lldb::RegisterContextSP m_thread_reg_ctx_sp;
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index 9e712f09e11..a1f0e607d4d 100644
--- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -133,7 +133,7 @@ UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly (AddressRange&
if (log && log->GetVerbose ())
{
StreamString strm;
- lldb::addr_t base_addr = range.GetBaseAddress().GetLoadAddress(&thread.GetProcess().GetTarget());
+ lldb::addr_t base_addr = range.GetBaseAddress().GetLoadAddress(thread.CalculateTarget().get());
strm.Printf ("Resulting unwind rows for [0x%llx - 0x%llx):", base_addr, base_addr + range.GetByteSize());
unwind_plan.Dump(strm, &thread, base_addr);
log->PutCString (strm.GetData());
@@ -153,8 +153,7 @@ UnwindAssemblyInstEmulation::GetFastUnwindPlan (AddressRange& func,
bool
UnwindAssemblyInstEmulation::FirstNonPrologueInsn (AddressRange& func,
- Target& target,
- Thread* thread,
+ const ExecutionContext &exe_ctx,
Address& first_non_prologue_insn)
{
return false;
diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
index b7025710333..3ee8cca88de 100644
--- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
+++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
@@ -38,8 +38,7 @@ public:
// thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch).
virtual bool
FirstNonPrologueInsn (lldb_private::AddressRange& func,
- lldb_private::Target& target,
- lldb_private::Thread* thread,
+ const lldb_private::ExecutionContext &exe_ctx,
lldb_private::Address& first_non_prologue_insn);
static lldb_private::UnwindAssembly *
diff --git a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
index 1379207e68e..c0daaac2882 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
@@ -117,7 +117,7 @@ static int x86_64_register_map_initialized = 0;
class AssemblyParse_x86 {
public:
- AssemblyParse_x86 (Target &target, Thread *thread, int cpu, AddressRange func);
+ AssemblyParse_x86 (const ExecutionContext &exe_ctx, int cpu, AddressRange func);
bool get_non_call_site_unwind_plan (UnwindPlan &unwind_plan);
@@ -140,8 +140,7 @@ private:
bool machine_regno_to_lldb_regno (int machine_regno, uint32_t& lldb_regno);
bool instruction_length (Address addr, int &length);
- Target &m_target;
- Thread* m_thread;
+ const ExecutionContext m_exe_ctx;
AddressRange m_func_bounds;
@@ -162,14 +161,20 @@ private:
DISALLOW_COPY_AND_ASSIGN (AssemblyParse_x86);
};
-AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, AddressRange func) :
- m_target (target), m_thread (thread), m_func_bounds(func), m_cur_insn (),
- m_machine_ip_regnum (-1), m_machine_sp_regnum (-1), m_machine_fp_regnum (-1),
- m_lldb_ip_regnum (-1), m_lldb_sp_regnum (-1), m_lldb_fp_regnum (-1),
- m_wordsize (-1), m_cpu(cpu)
+AssemblyParse_x86::AssemblyParse_x86 (const ExecutionContext &exe_ctx, int cpu, AddressRange func) :
+ m_exe_ctx (exe_ctx),
+ m_func_bounds(func),
+ m_cur_insn (),
+ m_machine_ip_regnum (LLDB_INVALID_REGNUM),
+ m_machine_sp_regnum (LLDB_INVALID_REGNUM),
+ m_machine_fp_regnum (LLDB_INVALID_REGNUM),
+ m_lldb_ip_regnum (LLDB_INVALID_REGNUM),
+ m_lldb_sp_regnum (LLDB_INVALID_REGNUM),
+ m_lldb_fp_regnum (LLDB_INVALID_REGNUM),
+ m_wordsize (-1),
+ m_cpu(cpu)
{
int *initialized_flag = NULL;
- m_lldb_ip_regnum = m_lldb_sp_regnum = m_lldb_fp_regnum = -1;
if (cpu == k_i386)
{
m_machine_ip_regnum = k_machine_eip;
@@ -191,9 +196,10 @@ AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, A
if (m_func_bounds.GetByteSize() == 0)
m_func_bounds.SetByteSize(512);
- if (m_thread && *initialized_flag == 0)
+ Thread *thread = m_exe_ctx.GetThreadPtr();
+ if (thread && *initialized_flag == 0)
{
- RegisterContext *reg_ctx = m_thread->GetRegisterContext().get();
+ RegisterContext *reg_ctx = thread->GetRegisterContext().get();
if (reg_ctx)
{
struct regmap_ent *ent;
@@ -501,7 +507,7 @@ AssemblyParse_x86::instruction_length (Address addr, int &length)
} InitializeLLVM;
EDDisassemblerRef disasm;
- EDInstRef cur_insn;
+ EDInstRef cur_insn;
if (EDGetDisassembler (&disasm, triple, kEDAssemblySyntaxX86ATT) != 0)
{
@@ -511,7 +517,7 @@ AssemblyParse_x86::instruction_length (Address addr, int &length)
uint64_t addr_offset = addr.GetOffset();
struct edis_byte_read_token arg;
arg.address = &addr;
- arg.target = &m_target;
+ arg.target = m_exe_ctx.GetTargetPtr();
if (EDCreateInsts (&cur_insn, 1, disasm, read_byte_for_edis, addr_offset, &arg) != 1)
{
return false;
@@ -558,6 +564,7 @@ AssemblyParse_x86::get_non_call_site_unwind_plan (UnwindPlan &unwind_plan)
unwind_plan.AppendRow (row);
const bool prefer_file_cache = true;
+ Target *target = m_exe_ctx.GetTargetPtr();
while (m_func_bounds.ContainsFileAddress (m_cur_insn) && non_prologue_insn_count < 10)
{
int stack_offset, insn_len;
@@ -569,7 +576,7 @@ AssemblyParse_x86::get_non_call_site_unwind_plan (UnwindPlan &unwind_plan)
// An unrecognized/junk instruction
break;
}
- if (m_target.ReadMemory (m_cur_insn, prefer_file_cache, m_cur_insn_bytes, insn_len, error) == -1)
+ if (target->ReadMemory (m_cur_insn, prefer_file_cache, m_cur_insn_bytes, insn_len, error) == -1)
{
// Error reading the instruction out of the file, stop scanning
break;
@@ -679,7 +686,7 @@ loopnext:
Address last_insn (m_func_bounds.GetBaseAddress());
last_insn.SetOffset (last_insn.GetOffset() + m_func_bounds.GetByteSize() - 1);
uint8_t bytebuf[1];
- if (m_target.ReadMemory (last_insn, prefer_file_cache, bytebuf, 1, error) != -1)
+ if (target->ReadMemory (last_insn, prefer_file_cache, bytebuf, 1, error) != -1)
{
if (bytebuf[0] == 0xc3) // ret aka retq
{
@@ -728,10 +735,12 @@ AssemblyParse_x86::get_fast_unwind_plan (AddressRange& func, UnwindPlan &unwind_
if (!func.GetBaseAddress().IsValid())
return false;
+ Target *target = m_exe_ctx.GetTargetPtr();
+
uint8_t bytebuf[4];
Error error;
const bool prefer_file_cache = true;
- if (m_target.ReadMemory (func.GetBaseAddress(), prefer_file_cache, bytebuf, sizeof (bytebuf), error) == -1)
+ if (target->ReadMemory (func.GetBaseAddress(), prefer_file_cache, bytebuf, sizeof (bytebuf), error) == -1)
return false;
uint8_t i386_prologue[] = {0x55, 0x89, 0xe5};
@@ -790,6 +799,7 @@ AssemblyParse_x86::find_first_non_prologue_insn (Address &address)
}
const bool prefer_file_cache = true;
+ Target *target = m_exe_ctx.GetTargetPtr();
while (m_func_bounds.ContainsFileAddress (m_cur_insn))
{
Error error;
@@ -799,7 +809,7 @@ AssemblyParse_x86::find_first_non_prologue_insn (Address &address)
// An error parsing the instruction, i.e. probably data/garbage - stop scanning
break;
}
- if (m_target.ReadMemory (m_cur_insn, prefer_file_cache, m_cur_insn_bytes, insn_len, error) == -1)
+ if (target->ReadMemory (m_cur_insn, prefer_file_cache, m_cur_insn_bytes, insn_len, error) == -1)
{
// Error reading the instruction out of the file, stop scanning
break;
@@ -843,21 +853,23 @@ UnwindAssembly_x86::~UnwindAssembly_x86 ()
bool
UnwindAssembly_x86::GetNonCallSiteUnwindPlanFromAssembly (AddressRange& func, Thread& thread, UnwindPlan& unwind_plan)
{
- AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func);
+ ExecutionContext exe_ctx (thread.shared_from_this());
+ AssemblyParse_x86 asm_parse(exe_ctx, m_cpu, func);
return asm_parse.get_non_call_site_unwind_plan (unwind_plan);
}
bool
UnwindAssembly_x86::GetFastUnwindPlan (AddressRange& func, Thread& thread, UnwindPlan &unwind_plan)
{
- AssemblyParse_x86 asm_parse(thread.GetProcess().GetTarget(), &thread, m_cpu, func);
+ ExecutionContext exe_ctx (thread.shared_from_this());
+ AssemblyParse_x86 asm_parse(exe_ctx, m_cpu, func);
return asm_parse.get_fast_unwind_plan (func, unwind_plan);
}
bool
-UnwindAssembly_x86::FirstNonPrologueInsn (AddressRange& func, Target& target, Thread* thread, Address& first_non_prologue_insn)
+UnwindAssembly_x86::FirstNonPrologueInsn (AddressRange& func, const ExecutionContext &exe_ctx, Address& first_non_prologue_insn)
{
- AssemblyParse_x86 asm_parse(target, thread, m_cpu, func);
+ AssemblyParse_x86 asm_parse(exe_ctx, m_cpu, func);
return asm_parse.find_first_non_prologue_insn (first_non_prologue_insn);
}
diff --git a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
index f5d039141b2..ac64e2c5194 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
+++ b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
@@ -32,8 +32,7 @@ public:
// thread may be NULL in which case we only use the Target (e.g. if this is called pre-process-launch).
virtual bool
FirstNonPrologueInsn (lldb_private::AddressRange& func,
- lldb_private::Target& target,
- lldb_private::Thread* thread,
+ const lldb_private::ExecutionContext &exe_ctx,
lldb_private::Address& first_non_prologue_insn);
static lldb_private::UnwindAssembly *
OpenPOWER on IntegriCloud