mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
Fixed issues with RegisterContext classes and the subclasses. There was
an issue with the way the UnwindLLDB was handing out RegisterContexts: it was making shared pointers to register contexts and then handing out just the pointers (which would get put into shared pointers in the thread and stack frame classes) and cause double free issues. MallocScribble helped to find these issues after I did some other cleanup. To help avoid any RegisterContext issue in the future, all code that deals with them now returns shared pointers to the register contexts so we don't end up with multiple deletions. Also now that the RegisterContext class doesn't require a stack frame, we patched a memory leak where a StackFrame object was being created and leaked. Made the RegisterContext class not have a pointer to a StackFrame object as one register context class can be used for N inlined stack frames so there is not a 1 - 1 mapping. Updates the ExecutionContextScope part of the RegisterContext class to never return a stack frame to indicate this when it is asked to recreate the execution context. Now register contexts point to the concrete frame using a concrete frame index. Concrete frames are all of the frames that are actually formed on the stack of a thread. These concrete frames can be turned into one or more user visible frames due to inlining. Each inlined stack frame has the exact same register context (shared via shared pointers) as any parent inlined stack frames all the way up to the concrete frame itself. So now the stack frames and the register contexts should behave much better. llvm-svn: 122976
This commit is contained in:
@@ -26,7 +26,7 @@ namespace lldb_private {
|
||||
class ValueObjectRegisterContext : public ValueObject
|
||||
{
|
||||
public:
|
||||
ValueObjectRegisterContext (ValueObject *parent, RegisterContext *reg_ctx);
|
||||
ValueObjectRegisterContext (ValueObject *parent, lldb::RegisterContextSP ®_ctx_sp);
|
||||
|
||||
virtual
|
||||
~ValueObjectRegisterContext();
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index);
|
||||
|
||||
protected:
|
||||
RegisterContext *m_reg_ctx;
|
||||
lldb::RegisterContextSP m_reg_ctx;
|
||||
|
||||
private:
|
||||
//------------------------------------------------------------------
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
class ValueObjectRegisterSet : public ValueObject
|
||||
{
|
||||
public:
|
||||
ValueObjectRegisterSet (ValueObject *parent, RegisterContext *reg_ctx, uint32_t set_idx);
|
||||
ValueObjectRegisterSet (ValueObject *parent, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx);
|
||||
|
||||
virtual
|
||||
~ValueObjectRegisterSet();
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
RegisterContext *m_reg_ctx;
|
||||
lldb::RegisterContextSP m_reg_ctx;
|
||||
const lldb::RegisterSet *m_reg_set;
|
||||
uint32_t m_reg_set_idx;
|
||||
|
||||
@@ -119,7 +119,7 @@ private:
|
||||
class ValueObjectRegister : public ValueObject
|
||||
{
|
||||
public:
|
||||
ValueObjectRegister (ValueObject *parent, RegisterContext *reg_ctx, uint32_t reg_num);
|
||||
ValueObjectRegister (ValueObject *parent, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num);
|
||||
|
||||
virtual
|
||||
~ValueObjectRegister();
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
RegisterContext *m_reg_ctx;
|
||||
lldb::RegisterContextSP m_reg_ctx;
|
||||
const lldb::RegisterInfo *m_reg_info;
|
||||
uint32_t m_reg_num;
|
||||
ConstString m_type_name;
|
||||
|
||||
@@ -26,9 +26,7 @@ public:
|
||||
//------------------------------------------------------------------
|
||||
// Constructors and Destructors
|
||||
//------------------------------------------------------------------
|
||||
RegisterContext (Thread &thread, StackFrame *frame);
|
||||
|
||||
RegisterContext (Thread &thread);
|
||||
RegisterContext (Thread &thread, uint32_t concrete_frame_idx);
|
||||
|
||||
virtual
|
||||
~RegisterContext ();
|
||||
@@ -147,9 +145,6 @@ public:
|
||||
bool
|
||||
ConvertBetweenRegisterKinds (int source_rk, uint32_t source_regnum, int target_rk, uint32_t& target_regnum);
|
||||
|
||||
void
|
||||
SetStackFrame (StackFrame *frame);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// lldb::ExecutionContextScope pure virtual functions
|
||||
//------------------------------------------------------------------
|
||||
@@ -172,8 +167,8 @@ protected:
|
||||
//------------------------------------------------------------------
|
||||
// Classes that inherit from RegisterContext can see and modify these
|
||||
//------------------------------------------------------------------
|
||||
Thread &m_thread; // The thread that this register context belongs to.
|
||||
StackFrame *m_frame; // The stack frame for this context, or NULL if this is the root context
|
||||
Thread &m_thread; // The thread that this register context belongs to.
|
||||
uint32_t m_concrete_frame_idx; // The concrete frame index for this register context
|
||||
private:
|
||||
//------------------------------------------------------------------
|
||||
// For RegisterContext only
|
||||
|
||||
@@ -34,14 +34,14 @@ public:
|
||||
// Constructors and Destructors
|
||||
//------------------------------------------------------------------
|
||||
StackFrame (lldb::user_id_t frame_idx,
|
||||
lldb::user_id_t unwind_frame_idx,
|
||||
lldb::user_id_t concrete_frame_idx,
|
||||
Thread &thread,
|
||||
lldb::addr_t cfa,
|
||||
lldb::addr_t pc,
|
||||
const SymbolContext *sc_ptr);
|
||||
|
||||
StackFrame (lldb::user_id_t frame_idx,
|
||||
lldb::user_id_t unwind_frame_idx,
|
||||
lldb::user_id_t concrete_frame_idx,
|
||||
Thread &thread,
|
||||
const lldb::RegisterContextSP ®_context_sp,
|
||||
lldb::addr_t cfa,
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
const SymbolContext *sc_ptr);
|
||||
|
||||
StackFrame (lldb::user_id_t frame_idx,
|
||||
lldb::user_id_t unwind_frame_idx,
|
||||
lldb::user_id_t concrete_frame_idx,
|
||||
Thread &thread,
|
||||
const lldb::RegisterContextSP ®_context_sp,
|
||||
lldb::addr_t cfa,
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
Block *
|
||||
GetFrameBlock ();
|
||||
|
||||
RegisterContext *
|
||||
lldb::RegisterContextSP
|
||||
GetRegisterContext ();
|
||||
|
||||
const lldb::RegisterContextSP &
|
||||
@@ -121,9 +121,9 @@ public:
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GetUnwindFrameIndex () const
|
||||
GetConcreteFrameIndex () const
|
||||
{
|
||||
return m_unwind_frame_index;
|
||||
return m_concrete_frame_index;
|
||||
}
|
||||
|
||||
lldb::ValueObjectSP
|
||||
@@ -173,7 +173,7 @@ private:
|
||||
//------------------------------------------------------------------
|
||||
Thread &m_thread;
|
||||
uint32_t m_frame_index;
|
||||
uint32_t m_unwind_frame_index;
|
||||
uint32_t m_concrete_frame_index;
|
||||
lldb::RegisterContextSP m_reg_context_sp;
|
||||
StackID m_id;
|
||||
Address m_frame_code_addr; // The frame code address (might not be the same as the actual PC for inlined frames) as a section/offset address
|
||||
|
||||
@@ -39,6 +39,9 @@ public:
|
||||
lldb::StackFrameSP
|
||||
GetFrameAtIndex (uint32_t idx);
|
||||
|
||||
lldb::StackFrameSP
|
||||
GetFrameWithConcreteFrameIndex (uint32_t unwind_idx);
|
||||
|
||||
// Mark a stack frame as the current frame
|
||||
uint32_t
|
||||
SetSelectedFrame (lldb_private::StackFrame *frame);
|
||||
|
||||
@@ -278,6 +278,9 @@ public:
|
||||
|
||||
virtual lldb::StackFrameSP
|
||||
GetStackFrameAtIndex (uint32_t idx);
|
||||
|
||||
virtual lldb::StackFrameSP
|
||||
GetFrameWithConcreteFrameIndex (uint32_t unwind_idx);
|
||||
|
||||
uint32_t
|
||||
GetSelectedFrameIndex ();
|
||||
@@ -291,7 +294,7 @@ public:
|
||||
void
|
||||
SetSelectedFrameByIndex (uint32_t frame_idx);
|
||||
|
||||
virtual RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
GetRegisterContext () = 0;
|
||||
|
||||
virtual bool
|
||||
@@ -300,7 +303,7 @@ public:
|
||||
virtual bool
|
||||
RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint) = 0;
|
||||
|
||||
virtual RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
CreateRegisterContextForFrame (StackFrame *frame) = 0;
|
||||
|
||||
virtual void
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
lldb::addr_t& cfa,
|
||||
lldb::addr_t& pc) = 0;
|
||||
|
||||
virtual RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
CreateRegisterContextForFrame (StackFrame *frame) = 0;
|
||||
|
||||
Thread &
|
||||
|
||||
@@ -426,7 +426,7 @@ SBFrame::FindValue (const char *name, ValueType value_type)
|
||||
|
||||
case eValueTypeRegister: // stack frame register value
|
||||
{
|
||||
RegisterContext *reg_ctx = m_opaque_sp->GetRegisterContext();
|
||||
RegisterContextSP reg_ctx (m_opaque_sp->GetRegisterContext());
|
||||
if (reg_ctx)
|
||||
{
|
||||
const uint32_t num_regs = reg_ctx->GetRegisterCount();
|
||||
@@ -446,7 +446,7 @@ SBFrame::FindValue (const char *name, ValueType value_type)
|
||||
|
||||
case eValueTypeRegisterSet: // A collection of stack frame register values
|
||||
{
|
||||
RegisterContext *reg_ctx = m_opaque_sp->GetRegisterContext();
|
||||
RegisterContextSP reg_ctx (m_opaque_sp->GetRegisterContext());
|
||||
if (reg_ctx)
|
||||
{
|
||||
const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
|
||||
@@ -640,7 +640,7 @@ SBFrame::GetRegisters ()
|
||||
if (m_opaque_sp)
|
||||
{
|
||||
Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
|
||||
RegisterContext *reg_ctx = m_opaque_sp->GetRegisterContext();
|
||||
RegisterContextSP reg_ctx (m_opaque_sp->GetRegisterContext());
|
||||
if (reg_ctx)
|
||||
{
|
||||
const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
|
||||
|
||||
@@ -959,7 +959,7 @@ Debugger::FormatPrompt
|
||||
}
|
||||
else if (::strncmp (var_name_begin, "reg.", strlen ("reg.")) == 0)
|
||||
{
|
||||
reg_ctx = exe_ctx->frame->GetRegisterContext();
|
||||
reg_ctx = exe_ctx->frame->GetRegisterContext().get();
|
||||
if (reg_ctx)
|
||||
{
|
||||
var_name_begin += ::strlen ("reg.");
|
||||
@@ -1100,7 +1100,7 @@ Debugger::FormatPrompt
|
||||
else
|
||||
{
|
||||
if (reg_ctx == NULL)
|
||||
reg_ctx = exe_ctx->frame->GetRegisterContext();
|
||||
reg_ctx = exe_ctx->frame->GetRegisterContext().get();
|
||||
|
||||
if (reg_ctx)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ using namespace lldb_private;
|
||||
|
||||
#pragma mark ValueObjectRegisterContext
|
||||
|
||||
ValueObjectRegisterContext::ValueObjectRegisterContext (ValueObject *parent, RegisterContext *reg_ctx) :
|
||||
ValueObjectRegisterContext::ValueObjectRegisterContext (ValueObject *parent, RegisterContextSP ®_ctx) :
|
||||
ValueObject (parent),
|
||||
m_reg_ctx (reg_ctx)
|
||||
{
|
||||
@@ -81,9 +81,9 @@ ValueObjectRegisterContext::UpdateValue (ExecutionContextScope *exe_scope)
|
||||
if (frame)
|
||||
m_reg_ctx = frame->GetRegisterContext();
|
||||
else
|
||||
m_reg_ctx = NULL;
|
||||
m_reg_ctx.reset();
|
||||
|
||||
SetValueIsValid (m_reg_ctx != NULL);
|
||||
SetValueIsValid (m_reg_ctx.get() != NULL);
|
||||
}
|
||||
|
||||
ValueObjectSP
|
||||
@@ -101,7 +101,7 @@ ValueObjectRegisterContext::CreateChildAtIndex (uint32_t idx, bool synthetic_arr
|
||||
#pragma mark -
|
||||
#pragma mark ValueObjectRegisterSet
|
||||
|
||||
ValueObjectRegisterSet::ValueObjectRegisterSet (ValueObject *parent, RegisterContext *reg_ctx, uint32_t reg_set_idx) :
|
||||
ValueObjectRegisterSet::ValueObjectRegisterSet (ValueObject *parent, lldb::RegisterContextSP ®_ctx, uint32_t reg_set_idx) :
|
||||
ValueObject (parent),
|
||||
m_reg_ctx (reg_ctx),
|
||||
m_reg_set (NULL),
|
||||
@@ -159,7 +159,7 @@ ValueObjectRegisterSet::UpdateValue (ExecutionContextScope *exe_scope)
|
||||
SetValueDidChange (false);
|
||||
StackFrame *frame = exe_scope->CalculateStackFrame();
|
||||
if (frame == NULL)
|
||||
m_reg_ctx = NULL;
|
||||
m_reg_ctx.reset();
|
||||
else
|
||||
{
|
||||
m_reg_ctx = frame->GetRegisterContext ();
|
||||
@@ -167,7 +167,7 @@ ValueObjectRegisterSet::UpdateValue (ExecutionContextScope *exe_scope)
|
||||
{
|
||||
const RegisterSet *reg_set = m_reg_ctx->GetRegisterSet (m_reg_set_idx);
|
||||
if (reg_set == NULL)
|
||||
m_reg_ctx = NULL;
|
||||
m_reg_ctx.reset();
|
||||
else if (m_reg_set != reg_set)
|
||||
{
|
||||
SetValueDidChange (true);
|
||||
@@ -204,7 +204,7 @@ ValueObjectRegisterSet::CreateChildAtIndex (uint32_t idx, bool synthetic_array_m
|
||||
#pragma mark -
|
||||
#pragma mark ValueObjectRegister
|
||||
|
||||
ValueObjectRegister::ValueObjectRegister (ValueObject *parent, RegisterContext *reg_ctx, uint32_t reg_num) :
|
||||
ValueObjectRegister::ValueObjectRegister (ValueObject *parent, lldb::RegisterContextSP ®_ctx, uint32_t reg_num) :
|
||||
ValueObject (parent),
|
||||
m_reg_ctx (reg_ctx),
|
||||
m_reg_info (NULL),
|
||||
@@ -310,7 +310,7 @@ ValueObjectRegister::UpdateValue (ExecutionContextScope *exe_scope)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_reg_ctx = NULL;
|
||||
m_reg_ctx.reset();
|
||||
m_reg_info = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -846,7 +846,7 @@ DWARFExpression::Evaluate
|
||||
std::vector<Value> stack;
|
||||
|
||||
if (reg_ctx == NULL && exe_ctx && exe_ctx->frame)
|
||||
reg_ctx = exe_ctx->frame->GetRegisterContext();
|
||||
reg_ctx = exe_ctx->frame->GetRegisterContext().get();
|
||||
|
||||
if (initial_value_ptr)
|
||||
stack.push_back(*initial_value_ptr);
|
||||
|
||||
@@ -61,7 +61,7 @@ ABIMacOSX_i386::PrepareTrivialCall (Thread &thread,
|
||||
lldb::addr_t *this_arg,
|
||||
lldb::addr_t *cmd_arg) const
|
||||
{
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
|
||||
if (!reg_ctx)
|
||||
return false;
|
||||
#define CHAIN_EBP
|
||||
@@ -154,7 +154,7 @@ ABIMacOSX_i386::PrepareNormalCall (Thread &thread,
|
||||
lldb::addr_t returnAddress,
|
||||
ValueList &args) const
|
||||
{
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
|
||||
if (!reg_ctx)
|
||||
return false;
|
||||
Error error;
|
||||
@@ -422,7 +422,7 @@ ABIMacOSX_i386::GetArgumentValues (Thread &thread,
|
||||
// Get the pointer to the first stack argument so we have a place to start
|
||||
// when reading data
|
||||
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
|
||||
|
||||
if (!reg_ctx)
|
||||
return false;
|
||||
@@ -498,7 +498,7 @@ ABIMacOSX_i386::GetReturnValue (Thread &thread,
|
||||
// Get the pointer to the first stack argument so we have a place to start
|
||||
// when reading data
|
||||
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
|
||||
|
||||
void *value_type = value.GetClangType();
|
||||
bool is_signed;
|
||||
|
||||
@@ -76,7 +76,7 @@ ABISysV_x86_64::PrepareTrivialCall (Thread &thread,
|
||||
cmd_arg,
|
||||
cmd_arg ? (uint64_t)*cmd_arg : (uint64_t)0);
|
||||
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
|
||||
if (!reg_ctx)
|
||||
return false;
|
||||
|
||||
@@ -293,7 +293,7 @@ ABISysV_x86_64::GetArgumentValues (Thread &thread,
|
||||
|
||||
// Extract the register context so we can read arguments from registers
|
||||
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
|
||||
|
||||
if (!reg_ctx)
|
||||
return false;
|
||||
@@ -382,7 +382,7 @@ ABISysV_x86_64::GetReturnValue (Thread &thread,
|
||||
void *value_type = value.GetClangType();
|
||||
bool is_signed;
|
||||
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
|
||||
|
||||
if (!reg_ctx)
|
||||
return false;
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual lldb_private::RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
CreateRegisterContext (lldb_private::StackFrame *frame) const = 0;
|
||||
|
||||
virtual void InitializeInstance() = 0;
|
||||
|
||||
@@ -71,17 +71,18 @@ MachThreadContext_arm::~MachThreadContext_arm()
|
||||
{
|
||||
}
|
||||
|
||||
RegisterContext *
|
||||
lldb::RegisterContextSP
|
||||
MachThreadContext_arm::CreateRegisterContext (StackFrame *frame) const
|
||||
{
|
||||
return new RegisterContextMach_arm(m_thread, frame);
|
||||
lldb::RegisterContextSP reg_ctx_sp (new RegisterContextMach_arm(m_thread, frame->GetConcreteFrameIndex()));
|
||||
return reg_ctx_sp;
|
||||
}
|
||||
|
||||
// Instance init function
|
||||
void
|
||||
MachThreadContext_arm::InitializeInstance()
|
||||
{
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
assert (reg_ctx != NULL);
|
||||
const RegisterInfo * reg_info;
|
||||
reg_info = reg_ctx->GetRegisterInfoByName ("bvr0");
|
||||
@@ -342,7 +343,7 @@ MachThreadContext_arm::EnableHardwareSingleStep (bool enable)
|
||||
if (m_bvr0_reg == LLDB_INVALID_REGNUM || m_bcr0_reg == LLDB_INVALID_REGNUM)
|
||||
return KERN_INVALID_ARGUMENT;
|
||||
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
uint32_t bvr = 0;
|
||||
uint32_t bcr = 0;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
virtual
|
||||
~MachThreadContext_arm();
|
||||
|
||||
virtual lldb_private::RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
CreateRegisterContext (lldb_private::StackFrame *frame) const;
|
||||
|
||||
virtual void
|
||||
|
||||
@@ -50,7 +50,7 @@ MachThreadContext_i386::Initialize()
|
||||
void
|
||||
MachThreadContext_i386::InitializeInstance()
|
||||
{
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
assert (reg_ctx != NULL);
|
||||
m_flags_reg = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ MachThreadContext_i386::NotifyException (MachException::Data& exc)
|
||||
case EXC_BREAKPOINT:
|
||||
if (exc.exc_data.size() >= 2 && exc.exc_data[0] == 2)
|
||||
{
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
assert (reg_ctx);
|
||||
lldb::addr_t pc = reg_ctx->GetPC(LLDB_INVALID_ADDRESS);
|
||||
if (pc != LLDB_INVALID_ADDRESS && pc > 0)
|
||||
@@ -152,10 +152,11 @@ MachThreadContext_i386::NotifyException (MachException::Data& exc)
|
||||
// return KERN_INVALID_ARGUMENT;
|
||||
//}
|
||||
|
||||
RegisterContext *
|
||||
RegisterContextSP
|
||||
MachThreadContext_i386::CreateRegisterContext (StackFrame *frame) const
|
||||
{
|
||||
return new RegisterContextMach_i386(m_thread, frame);
|
||||
lldb::RegisterContextSP reg_ctx_sp (new RegisterContextMach_i386(m_thread, frame->GetConcreteFrameIndex()));
|
||||
return reg_ctx_sp;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +173,7 @@ MachThreadContext_i386::GetStackFrameData(StackFrame *first_frame, std::vector<s
|
||||
uint32_t pc;
|
||||
};
|
||||
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
assert (reg_ctx);
|
||||
|
||||
Frame_i386 frame = { reg_ctx->GetFP(0), reg_ctx->GetPC(LLDB_INVALID_ADDRESS) };
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
virtual
|
||||
~MachThreadContext_i386();
|
||||
|
||||
virtual lldb_private::RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
CreateRegisterContext (lldb_private::StackFrame *frame) const;
|
||||
|
||||
virtual void InitializeInstance();
|
||||
|
||||
@@ -49,7 +49,7 @@ MachThreadContext_x86_64::Initialize()
|
||||
void
|
||||
MachThreadContext_x86_64::InitializeInstance()
|
||||
{
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
assert (reg_ctx != NULL);
|
||||
m_flags_reg = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ MachThreadContext_x86_64::NotifyException(MachException::Data& exc)
|
||||
case EXC_BREAKPOINT:
|
||||
if (exc.exc_data.size() >= 2 && exc.exc_data[0] == 2)
|
||||
{
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
assert (reg_ctx);
|
||||
lldb::addr_t pc = reg_ctx->GetPC(LLDB_INVALID_ADDRESS);
|
||||
if (pc != LLDB_INVALID_ADDRESS && pc > 0)
|
||||
@@ -158,10 +158,11 @@ MachThreadContext_x86_64::NotifyException(MachException::Data& exc)
|
||||
|
||||
|
||||
|
||||
RegisterContext *
|
||||
RegisterContextSP
|
||||
MachThreadContext_x86_64::CreateRegisterContext (StackFrame *frame) const
|
||||
{
|
||||
return new RegisterContextMach_x86_64(m_thread, frame);
|
||||
lldb::RegisterContextSP reg_ctx_sp (new RegisterContextMach_x86_64(m_thread, frame->GetConcreteFrameIndex()));
|
||||
return reg_ctx_sp;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +186,7 @@ MachThreadContext_x86_64::GetStackFrameData(StackFrame *first_frame, std::vector
|
||||
uint64_t pc;
|
||||
};
|
||||
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
assert (reg_ctx);
|
||||
|
||||
Frame_x86_64 frame = { reg_ctx->GetFP(0), reg_ctx->GetPC(LLDB_INVALID_ADDRESS) };
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
virtual
|
||||
~MachThreadContext_x86_64();
|
||||
|
||||
virtual lldb_private::RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
CreateRegisterContext (lldb_private::StackFrame *frame) const;
|
||||
|
||||
virtual void
|
||||
|
||||
@@ -157,8 +157,8 @@ enum
|
||||
};
|
||||
|
||||
|
||||
RegisterContextMach_arm::RegisterContextMach_arm(Thread &thread, StackFrame *frame) :
|
||||
RegisterContext(thread, frame),
|
||||
RegisterContextMach_arm::RegisterContextMach_arm(Thread &thread, uint32_t concrete_frame_idx) :
|
||||
RegisterContext(thread, concrete_frame_idx),
|
||||
gpr(),
|
||||
fpu(),
|
||||
exc()
|
||||
|
||||
@@ -54,7 +54,7 @@ class RegisterContextMach_arm : public lldb_private::RegisterContext
|
||||
{
|
||||
public:
|
||||
|
||||
RegisterContextMach_arm(lldb_private::Thread &thread, lldb_private::StackFrame *frame);
|
||||
RegisterContextMach_arm(lldb_private::Thread &thread, uint32_t concrete_frame_idx);
|
||||
|
||||
virtual
|
||||
~RegisterContextMach_arm();
|
||||
|
||||
@@ -183,8 +183,8 @@ enum
|
||||
gdb_mm7 = 48
|
||||
};
|
||||
|
||||
RegisterContextMach_i386::RegisterContextMach_i386 (Thread &thread, StackFrame *frame) :
|
||||
RegisterContext(thread, frame),
|
||||
RegisterContextMach_i386::RegisterContextMach_i386 (Thread &thread, uint32_t concrete_frame_idx) :
|
||||
RegisterContext(thread, concrete_frame_idx),
|
||||
gpr(),
|
||||
fpu(),
|
||||
exc()
|
||||
|
||||
@@ -22,7 +22,7 @@ class RegisterContextMach_i386 : public lldb_private::RegisterContext
|
||||
public:
|
||||
|
||||
RegisterContextMach_i386(lldb_private::Thread &thread,
|
||||
lldb_private::StackFrame *frame);
|
||||
uint32_t concrete_frame_idx);
|
||||
|
||||
virtual
|
||||
~RegisterContextMach_i386();
|
||||
|
||||
@@ -206,8 +206,8 @@ enum gdb_regnums
|
||||
gdb_fpu_mxcsr = 56,
|
||||
};
|
||||
|
||||
RegisterContextMach_x86_64::RegisterContextMach_x86_64 (Thread &thread, StackFrame *frame) :
|
||||
RegisterContext (thread, frame),
|
||||
RegisterContextMach_x86_64::RegisterContextMach_x86_64 (Thread &thread, uint32_t concrete_frame_idx) :
|
||||
RegisterContext (thread, concrete_frame_idx),
|
||||
gpr(),
|
||||
fpu(),
|
||||
exc()
|
||||
|
||||
@@ -21,7 +21,7 @@ class RegisterContextMach_x86_64 : public lldb_private::RegisterContext
|
||||
{
|
||||
public:
|
||||
RegisterContextMach_x86_64 (lldb_private::Thread &thread,
|
||||
lldb_private::StackFrame *frame);
|
||||
uint32_t concrete_frame_idx);
|
||||
|
||||
virtual
|
||||
~RegisterContextMach_x86_64();
|
||||
|
||||
@@ -444,7 +444,7 @@ ThreadMacOSX::Dump(Log *log, uint32_t index)
|
||||
default: thread_run_state = "???"; break;
|
||||
}
|
||||
|
||||
RegisterContext *reg_context = GetRegisterContext();
|
||||
RegisterContext *reg_context = GetRegisterContext().get();
|
||||
log->Printf ("thread[%u] %4.4x (%u): pc: 0x%8.8llx sp: 0x%8.8llx breakID: %d user: %d.%06.6d system: %d.%06.6d cpu: %d policy: %d run_state: %d (%s) flags: %d suspend_count: %d (current %d) sleep_time: %d",
|
||||
index,
|
||||
GetID (),
|
||||
@@ -597,15 +597,15 @@ ThreadMacOSX::NotifyException(MachException::Data& exc)
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterContext *
|
||||
RegisterContextSP
|
||||
ThreadMacOSX::GetRegisterContext ()
|
||||
{
|
||||
if (m_reg_context_sp.get() == NULL)
|
||||
m_reg_context_sp.reset (CreateRegisterContextForFrame (NULL));
|
||||
return m_reg_context_sp.get();
|
||||
m_reg_context_sp = CreateRegisterContextForFrame (NULL);
|
||||
return m_reg_context_sp;
|
||||
}
|
||||
|
||||
RegisterContext *
|
||||
RegisterContextSP
|
||||
ThreadMacOSX::CreateRegisterContextForFrame (StackFrame *frame)
|
||||
{
|
||||
return m_context->CreateRegisterContext (frame);
|
||||
|
||||
@@ -39,10 +39,10 @@ public:
|
||||
virtual const char *
|
||||
GetName ();
|
||||
|
||||
virtual lldb_private::RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
GetRegisterContext ();
|
||||
|
||||
virtual lldb_private::RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
|
||||
|
||||
virtual bool
|
||||
|
||||
@@ -56,7 +56,7 @@ ArchVolatileRegs_x86::initialize_regset(Thread& thread)
|
||||
return;
|
||||
|
||||
|
||||
RegisterContext *rctx = thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
|
||||
const RegisterInfo *ri;
|
||||
|
||||
const char *x86_64_regnames[] = { "rbx",
|
||||
@@ -91,7 +91,7 @@ ArchVolatileRegs_x86::initialize_regset(Thread& thread)
|
||||
|
||||
for (int i = 0; i < namecount; i++)
|
||||
{
|
||||
ri = rctx->GetRegisterInfoByName (names[i]);
|
||||
ri = reg_ctx->GetRegisterInfoByName (names[i]);
|
||||
if (ri)
|
||||
m_non_volatile_regs.insert (ri->kinds[eRegisterKindLLDB]);
|
||||
}
|
||||
|
||||
@@ -31,19 +31,32 @@ using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
||||
|
||||
RegisterContextLLDB::RegisterContextLLDB (Thread& thread,
|
||||
const RegisterContextSP &next_frame,
|
||||
SymbolContext& sym_ctx,
|
||||
int frame_number) :
|
||||
RegisterContext (thread), m_thread(thread), m_next_frame(next_frame),
|
||||
m_sym_ctx(sym_ctx), m_all_registers_available(false), m_registers(),
|
||||
m_cfa (LLDB_INVALID_ADDRESS), m_start_pc (), m_current_pc (), m_frame_number (frame_number),
|
||||
m_full_unwind_plan(NULL), m_fast_unwind_plan(NULL), m_base_reg_ctx (), m_frame_type (-1),
|
||||
m_current_offset (0), m_current_offset_backed_up_one (0), m_sym_ctx_valid (false)
|
||||
RegisterContextLLDB::RegisterContextLLDB
|
||||
(
|
||||
Thread& thread,
|
||||
const RegisterContextSP &next_frame,
|
||||
SymbolContext& sym_ctx,
|
||||
uint32_t frame_number
|
||||
) :
|
||||
RegisterContext (thread, frame_number),
|
||||
m_thread(thread),
|
||||
m_next_frame(next_frame),
|
||||
m_sym_ctx(sym_ctx),
|
||||
m_all_registers_available(false),
|
||||
m_registers(),
|
||||
m_cfa (LLDB_INVALID_ADDRESS),
|
||||
m_start_pc (),
|
||||
m_current_pc (),
|
||||
m_frame_number (frame_number),
|
||||
m_full_unwind_plan(NULL),
|
||||
m_fast_unwind_plan(NULL),
|
||||
m_frame_type (-1),
|
||||
m_current_offset (0),
|
||||
m_current_offset_backed_up_one (0),
|
||||
m_sym_ctx_valid (false)
|
||||
{
|
||||
m_sym_ctx.Clear();
|
||||
m_sym_ctx_valid = false;
|
||||
m_base_reg_ctx = m_thread.GetRegisterContext();
|
||||
|
||||
if (IsFrameZero ())
|
||||
{
|
||||
@@ -81,7 +94,8 @@ void
|
||||
RegisterContextLLDB::InitializeZerothFrame()
|
||||
{
|
||||
StackFrameSP frame_sp (m_thread.GetStackFrameAtIndex (0));
|
||||
if (m_base_reg_ctx == NULL)
|
||||
|
||||
if (m_thread.GetRegisterContext() == NULL)
|
||||
{
|
||||
m_frame_type = eNotAValidFrame;
|
||||
return;
|
||||
@@ -160,7 +174,7 @@ RegisterContextLLDB::InitializeZerothFrame()
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d could not find a valid cfa address",
|
||||
log->Printf("%*sFrame %u could not find a valid cfa address",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
|
||||
}
|
||||
m_frame_type = eNotAValidFrame;
|
||||
@@ -169,7 +183,7 @@ RegisterContextLLDB::InitializeZerothFrame()
|
||||
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sThread %d Frame %d initialized frame current pc is 0x%llx cfa is 0x%llx using %s UnwindPlan",
|
||||
log->Printf("%*sThread %d Frame %u initialized frame current pc is 0x%llx cfa is 0x%llx using %s UnwindPlan",
|
||||
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_cfa,
|
||||
m_full_unwind_plan->GetSourceName().GetCString());
|
||||
@@ -193,7 +207,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
|
||||
m_frame_type = eNotAValidFrame;
|
||||
return;
|
||||
}
|
||||
if (m_base_reg_ctx == NULL)
|
||||
if (m_thread.GetRegisterContext() == NULL)
|
||||
{
|
||||
m_frame_type = eNotAValidFrame;
|
||||
return;
|
||||
@@ -204,7 +218,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d could not get pc value",
|
||||
log->Printf("%*sFrame %u could not get pc value",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
|
||||
}
|
||||
m_frame_type = eNotAValidFrame;
|
||||
@@ -224,7 +238,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d using architectural default unwind method",
|
||||
log->Printf("%*sFrame %u using architectural default unwind method",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
|
||||
}
|
||||
ArchSpec arch = m_thread.GetProcess().GetTarget().GetArchitecture ();
|
||||
@@ -245,7 +259,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d failed to get cfa value",
|
||||
log->Printf("%*sFrame %u failed to get cfa value",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
|
||||
}
|
||||
m_frame_type = eNormalFrame;
|
||||
@@ -258,7 +272,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d could not find a valid cfa address",
|
||||
log->Printf("%*sFrame %u could not find a valid cfa address",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
|
||||
}
|
||||
m_frame_type = eNotAValidFrame;
|
||||
@@ -267,7 +281,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
|
||||
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d initialized frame cfa is 0x%llx",
|
||||
log->Printf("%*sFrame %u initialized frame cfa is 0x%llx",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
(uint64_t) m_cfa);
|
||||
}
|
||||
@@ -392,7 +406,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d failed to get cfa reg %d/%d",
|
||||
log->Printf("%*sFrame %u failed to get cfa reg %d/%d",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
row_register_kind, active_row->GetCFARegister());
|
||||
}
|
||||
@@ -408,7 +422,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d could not find a valid cfa address",
|
||||
log->Printf("%*sFrame %u could not find a valid cfa address",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
|
||||
}
|
||||
m_frame_type = eNotAValidFrame;
|
||||
@@ -417,7 +431,7 @@ RegisterContextLLDB::InitializeNonZerothFrame()
|
||||
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d initialized frame current pc is 0x%llx cfa is 0x%llx",
|
||||
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);
|
||||
}
|
||||
@@ -478,7 +492,7 @@ RegisterContextLLDB::GetFastUnwindPlanForFrame ()
|
||||
const char *has_fast = "";
|
||||
if (m_fast_unwind_plan)
|
||||
has_fast = ", and has a fast UnwindPlan";
|
||||
log->Printf("%*sFrame %d frame has a fast UnwindPlan",
|
||||
log->Printf("%*sFrame %u frame has a fast UnwindPlan",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number);
|
||||
}
|
||||
m_frame_type = eNormalFrame;
|
||||
@@ -570,7 +584,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
|
||||
{
|
||||
if (log && IsLogVerbose())
|
||||
{
|
||||
log->Printf("%*sFrame %d frame uses %s for full UnwindPlan",
|
||||
log->Printf("%*sFrame %u frame uses %s for full UnwindPlan",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
up->GetSourceName().GetCString());
|
||||
}
|
||||
@@ -583,7 +597,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
|
||||
{
|
||||
if (log && IsLogVerbose())
|
||||
{
|
||||
log->Printf("%*sFrame %d frame uses %s for full UnwindPlan",
|
||||
log->Printf("%*sFrame %u frame uses %s for full UnwindPlan",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
up->GetSourceName().GetCString());
|
||||
}
|
||||
@@ -597,7 +611,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
|
||||
{
|
||||
if (log && IsLogVerbose())
|
||||
{
|
||||
log->Printf("%*sFrame %d frame uses %s for full UnwindPlan",
|
||||
log->Printf("%*sFrame %u frame uses %s for full UnwindPlan",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
up->GetSourceName().GetCString());
|
||||
}
|
||||
@@ -607,7 +621,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame ()
|
||||
// If nothing else, use the architectural default UnwindPlan and hope that does the job.
|
||||
if (log && IsLogVerbose())
|
||||
{
|
||||
log->Printf("%*sFrame %d frame uses %s for full UnwindPlan",
|
||||
log->Printf("%*sFrame %u frame uses %s for full UnwindPlan",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
arch_default_up->GetSourceName().GetCString());
|
||||
}
|
||||
@@ -624,31 +638,31 @@ RegisterContextLLDB::Invalidate ()
|
||||
size_t
|
||||
RegisterContextLLDB::GetRegisterCount ()
|
||||
{
|
||||
return m_base_reg_ctx->GetRegisterCount();
|
||||
return m_thread.GetRegisterContext()->GetRegisterCount();
|
||||
}
|
||||
|
||||
const RegisterInfo *
|
||||
RegisterContextLLDB::GetRegisterInfoAtIndex (uint32_t reg)
|
||||
{
|
||||
return m_base_reg_ctx->GetRegisterInfoAtIndex (reg);
|
||||
return m_thread.GetRegisterContext()->GetRegisterInfoAtIndex (reg);
|
||||
}
|
||||
|
||||
size_t
|
||||
RegisterContextLLDB::GetRegisterSetCount ()
|
||||
{
|
||||
return m_base_reg_ctx->GetRegisterSetCount ();
|
||||
return m_thread.GetRegisterContext()->GetRegisterSetCount ();
|
||||
}
|
||||
|
||||
const RegisterSet *
|
||||
RegisterContextLLDB::GetRegisterSet (uint32_t reg_set)
|
||||
{
|
||||
return m_base_reg_ctx->GetRegisterSet (reg_set);
|
||||
return m_thread.GetRegisterContext()->GetRegisterSet (reg_set);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
RegisterContextLLDB::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num)
|
||||
{
|
||||
return m_base_reg_ctx->ConvertRegisterKindToRegisterNumber (kind, num);
|
||||
return m_thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber (kind, num);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -663,7 +677,7 @@ RegisterContextLLDB::ReadRegisterBytesFromRegisterLocation (uint32_t regnum, Reg
|
||||
data.SetByteOrder (m_thread.GetProcess().GetByteOrder());
|
||||
if (IsFrameZero ())
|
||||
{
|
||||
return m_base_reg_ctx->ReadRegisterBytes (regloc.location.register_number, data);
|
||||
return m_thread.GetRegisterContext()->ReadRegisterBytes (regloc.location.register_number, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -683,7 +697,7 @@ RegisterContextLLDB::ReadRegisterBytesFromRegisterLocation (uint32_t regnum, Reg
|
||||
assert ("Unknown RegisterLocation type.");
|
||||
}
|
||||
|
||||
const RegisterInfo *reg_info = m_base_reg_ctx->GetRegisterInfoAtIndex (regnum);
|
||||
const RegisterInfo *reg_info = m_thread.GetRegisterContext()->GetRegisterInfoAtIndex (regnum);
|
||||
DataBufferSP data_sp (new DataBufferHeap (reg_info->byte_size, 0));
|
||||
data.SetData (data_sp, 0, reg_info->byte_size);
|
||||
data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize());
|
||||
@@ -743,7 +757,7 @@ RegisterContextLLDB::WriteRegisterBytesToRegisterLocation (uint32_t regnum, Regi
|
||||
{
|
||||
if (IsFrameZero ())
|
||||
{
|
||||
return m_base_reg_ctx->WriteRegisterBytes (regloc.location.register_number, data, data_offset);
|
||||
return m_thread.GetRegisterContext()->WriteRegisterBytes (regloc.location.register_number, data, data_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -768,7 +782,7 @@ RegisterContextLLDB::WriteRegisterBytesToRegisterLocation (uint32_t regnum, Regi
|
||||
}
|
||||
|
||||
Error error;
|
||||
const RegisterInfo *reg_info = m_base_reg_ctx->GetRegisterInfoAtIndex (regnum);
|
||||
const RegisterInfo *reg_info = m_thread.GetRegisterContext()->GetRegisterInfoAtIndex (regnum);
|
||||
if (reg_info->byte_size == 0)
|
||||
return false;
|
||||
uint8_t *buf = (uint8_t*) alloca (reg_info->byte_size);
|
||||
@@ -809,7 +823,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
// Are we looking for the CALLER's stack pointer? The stack pointer is defined to be the same as THIS frame's
|
||||
// CFA so just return the CFA value. This is true on x86-32/x86-64 at least.
|
||||
uint32_t sp_regnum;
|
||||
if (m_base_reg_ctx->ConvertBetweenRegisterKinds (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, eRegisterKindLLDB, sp_regnum)
|
||||
if (m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, eRegisterKindLLDB, sp_regnum)
|
||||
&& sp_regnum == lldb_regnum)
|
||||
{
|
||||
// make sure we won't lose precision copying an addr_t (m_cfa) into a uint64_t (.register_value)
|
||||
@@ -831,11 +845,11 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
const UnwindPlan::Row *active_row = m_fast_unwind_plan->GetRowForFunctionOffset (m_current_offset);
|
||||
unwindplan_registerkind = m_fast_unwind_plan->GetRegisterKind ();
|
||||
uint32_t row_regnum;
|
||||
if (!m_base_reg_ctx->ConvertBetweenRegisterKinds (eRegisterKindLLDB, lldb_regnum, unwindplan_registerkind, row_regnum))
|
||||
if (!m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindLLDB, lldb_regnum, unwindplan_registerkind, row_regnum))
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d could not convert lldb regnum %d into %d RegisterKind reg numbering scheme",
|
||||
log->Printf("%*sFrame %u could not convert lldb regnum %d into %d RegisterKind reg numbering scheme",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum, (int) unwindplan_registerkind);
|
||||
}
|
||||
@@ -845,7 +859,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d supplying caller's saved reg %d's location using FastUnwindPlan",
|
||||
log->Printf("%*sFrame %u supplying caller's saved reg %d's location using FastUnwindPlan",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum);
|
||||
}
|
||||
@@ -865,16 +879,16 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
const UnwindPlan::Row *active_row = m_full_unwind_plan->GetRowForFunctionOffset (m_current_offset);
|
||||
unwindplan_registerkind = m_full_unwind_plan->GetRegisterKind ();
|
||||
uint32_t row_regnum;
|
||||
if (!m_base_reg_ctx->ConvertBetweenRegisterKinds (eRegisterKindLLDB, lldb_regnum, unwindplan_registerkind, row_regnum))
|
||||
if (!m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindLLDB, lldb_regnum, unwindplan_registerkind, row_regnum))
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
if (unwindplan_registerkind == eRegisterKindGeneric)
|
||||
log->Printf("%*sFrame %d could not convert lldb regnum %d into eRegisterKindGeneric reg numbering scheme",
|
||||
log->Printf("%*sFrame %u could not convert lldb regnum %d into eRegisterKindGeneric reg numbering scheme",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum);
|
||||
else
|
||||
log->Printf("%*sFrame %d could not convert lldb regnum %d into %d RegisterKind reg numbering scheme",
|
||||
log->Printf("%*sFrame %u could not convert lldb regnum %d into %d RegisterKind reg numbering scheme",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum, (int) unwindplan_registerkind);
|
||||
}
|
||||
@@ -886,7 +900,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
have_unwindplan_regloc = true;
|
||||
if (log && IsLogVerbose ())
|
||||
{
|
||||
log->Printf("%*sFrame %d supplying caller's saved reg %d's location using %s UnwindPlan",
|
||||
log->Printf("%*sFrame %u supplying caller's saved reg %d's location using %s UnwindPlan",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum, m_full_unwind_plan->GetSourceName().GetCString());
|
||||
}
|
||||
@@ -904,7 +918,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d did not supply reg location for %d because it is volatile",
|
||||
log->Printf("%*sFrame %u did not supply reg location for %d because it is volatile",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum);
|
||||
}
|
||||
@@ -927,7 +941,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
}
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d could not supply caller's reg %d location",
|
||||
log->Printf("%*sFrame %u could not supply caller's reg %d location",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum);
|
||||
}
|
||||
@@ -942,7 +956,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
m_registers[lldb_regnum] = new_regloc;
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d could not supply caller's reg %d location",
|
||||
log->Printf("%*sFrame %u could not supply caller's reg %d location",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum);
|
||||
}
|
||||
@@ -959,7 +973,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d could not supply caller's reg %d location",
|
||||
log->Printf("%*sFrame %u could not supply caller's reg %d location",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum);
|
||||
}
|
||||
@@ -989,11 +1003,11 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
{
|
||||
uint32_t unwindplan_regnum = unwindplan_regloc.GetRegisterNumber();
|
||||
uint32_t row_regnum_in_lldb;
|
||||
if (!m_base_reg_ctx->ConvertBetweenRegisterKinds (unwindplan_registerkind, unwindplan_regnum, eRegisterKindLLDB, row_regnum_in_lldb))
|
||||
if (!m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (unwindplan_registerkind, unwindplan_regnum, eRegisterKindLLDB, row_regnum_in_lldb))
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d could not supply caller's reg %d location",
|
||||
log->Printf("%*sFrame %u could not supply caller's reg %d location",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum);
|
||||
}
|
||||
@@ -1036,7 +1050,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
}
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d tried to use IsDWARFExpression or IsAtDWARFExpression for reg %d but failed",
|
||||
log->Printf("%*sFrame %u tried to use IsDWARFExpression or IsAtDWARFExpression for reg %d but failed",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum);
|
||||
}
|
||||
@@ -1045,7 +1059,7 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d could not supply caller's reg %d location",
|
||||
log->Printf("%*sFrame %u could not supply caller's reg %d location",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_regnum);
|
||||
}
|
||||
@@ -1069,7 +1083,6 @@ RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, RegisterLoc
|
||||
// and this RegisterContext is for frame 1 (bar) - if we want to get the pc value for frame 1, we need to ask
|
||||
// where frame 0 (the "next" frame) saved that and retrieve the value.
|
||||
|
||||
// Assumes m_base_reg_ctx has been set
|
||||
bool
|
||||
RegisterContextLLDB::ReadGPRValue (int register_kind, uint32_t regnum, addr_t &value)
|
||||
{
|
||||
@@ -1081,7 +1094,7 @@ RegisterContextLLDB::ReadGPRValue (int register_kind, uint32_t regnum, addr_t &v
|
||||
{
|
||||
lldb_regnum = regnum;
|
||||
}
|
||||
else if (!m_base_reg_ctx->ConvertBetweenRegisterKinds (register_kind, regnum, eRegisterKindLLDB, lldb_regnum))
|
||||
else if (!m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (register_kind, regnum, eRegisterKindLLDB, lldb_regnum))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1094,7 +1107,7 @@ RegisterContextLLDB::ReadGPRValue (int register_kind, uint32_t regnum, addr_t &v
|
||||
// if this is frame 0 (currently executing frame), get the requested reg contents from the actual thread registers
|
||||
if (IsFrameZero ())
|
||||
{
|
||||
if (m_base_reg_ctx->ReadRegisterBytes (lldb_regnum, data))
|
||||
if (m_thread.GetRegisterContext()->ReadRegisterBytes (lldb_regnum, data))
|
||||
{
|
||||
data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize());
|
||||
value = data.GetAddress (&offset);
|
||||
@@ -1131,7 +1144,7 @@ RegisterContextLLDB::ReadRegisterBytes (uint32_t lldb_reg, DataExtractor& data)
|
||||
|
||||
if (log && IsLogVerbose ())
|
||||
{
|
||||
log->Printf("%*sFrame %d looking for register saved location for reg %d",
|
||||
log->Printf("%*sFrame %u looking for register saved location for reg %d",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_reg);
|
||||
}
|
||||
@@ -1141,11 +1154,11 @@ RegisterContextLLDB::ReadRegisterBytes (uint32_t lldb_reg, DataExtractor& data)
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d passing along to the live register context for reg %d",
|
||||
log->Printf("%*sFrame %u passing along to the live register context for reg %d",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_reg);
|
||||
}
|
||||
return m_base_reg_ctx->ReadRegisterBytes (lldb_reg, data);
|
||||
return m_thread.GetRegisterContext()->ReadRegisterBytes (lldb_reg, data);
|
||||
}
|
||||
|
||||
RegisterLocation regloc;
|
||||
@@ -1165,7 +1178,7 @@ RegisterContextLLDB::WriteRegisterBytes (uint32_t lldb_reg, DataExtractor &data,
|
||||
|
||||
if (log && IsLogVerbose ())
|
||||
{
|
||||
log->Printf("%*sFrame %d looking for register saved location for reg %d",
|
||||
log->Printf("%*sFrame %u looking for register saved location for reg %d",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_reg);
|
||||
}
|
||||
@@ -1175,11 +1188,11 @@ RegisterContextLLDB::WriteRegisterBytes (uint32_t lldb_reg, DataExtractor &data,
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d passing along to the live register context for reg %d",
|
||||
log->Printf("%*sFrame %u passing along to the live register context for reg %d",
|
||||
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
|
||||
lldb_reg);
|
||||
}
|
||||
return m_base_reg_ctx->WriteRegisterBytes (lldb_reg, data, data_offset);
|
||||
return m_thread.GetRegisterContext()->WriteRegisterBytes (lldb_reg, data, data_offset);
|
||||
}
|
||||
|
||||
RegisterLocation regloc;
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
RegisterContextLLDB (lldb_private::Thread &thread,
|
||||
const lldb::RegisterContextSP& next_frame,
|
||||
lldb_private::SymbolContext& sym_ctx,
|
||||
int frame_number);
|
||||
uint32_t frame_number);
|
||||
|
||||
///
|
||||
// pure virtual functions from the base class that we must implement
|
||||
@@ -156,8 +156,6 @@ private:
|
||||
lldb_private::Thread& m_thread;
|
||||
lldb::RegisterContextSP m_next_frame;
|
||||
|
||||
lldb_private::RegisterContext *m_base_reg_ctx; // RegisterContext of frame 0 (live register values only)
|
||||
|
||||
///
|
||||
// The following tell us how to retrieve the CALLER's register values (ie the "previous" frame, aka the frame above)
|
||||
// i.e. where THIS frame saved them
|
||||
@@ -186,7 +184,7 @@ private:
|
||||
lldb_private::SymbolContext& m_sym_ctx;
|
||||
bool m_sym_ctx_valid; // if ResolveSymbolContextForAddress fails, don't try to use m_sym_ctx
|
||||
|
||||
int m_frame_number; // What stack frame level this frame is - used for debug logging
|
||||
uint32_t m_frame_number; // What stack frame level this frame is - used for debug logging
|
||||
|
||||
std::map<uint32_t, RegisterLocation> m_registers; // where to find reg values for this frame
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ using namespace lldb_private;
|
||||
RegisterContextMacOSXFrameBackchain::RegisterContextMacOSXFrameBackchain
|
||||
(
|
||||
Thread &thread,
|
||||
StackFrame *frame,
|
||||
uint32_t concrete_frame_idx,
|
||||
const UnwindMacOSXFrameBackchain::Cursor &cursor
|
||||
) :
|
||||
RegisterContext (thread, frame),
|
||||
RegisterContext (thread, concrete_frame_idx),
|
||||
m_cursor (cursor),
|
||||
m_cursor_is_valid (true)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
// Constructors and Destructors
|
||||
//------------------------------------------------------------------
|
||||
RegisterContextMacOSXFrameBackchain (lldb_private::Thread &thread,
|
||||
lldb_private::StackFrame *frame,
|
||||
uint32_t concrete_frame_idx,
|
||||
const UnwindMacOSXFrameBackchain::Cursor &cursor);
|
||||
|
||||
virtual
|
||||
|
||||
@@ -197,8 +197,8 @@ AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, A
|
||||
|
||||
if (m_thread && *initialized_flag == 0)
|
||||
{
|
||||
RegisterContext *rctx = m_thread->GetRegisterContext();
|
||||
if (rctx)
|
||||
RegisterContext *reg_ctx = m_thread->GetRegisterContext().get();
|
||||
if (reg_ctx)
|
||||
{
|
||||
struct regmap_ent *ent;
|
||||
int count, i;
|
||||
@@ -214,7 +214,7 @@ AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, A
|
||||
}
|
||||
for (i = 0; i < count; i++, ent++)
|
||||
{
|
||||
const RegisterInfo *ri = rctx->GetRegisterInfoByName (ent->name);
|
||||
const RegisterInfo *ri = reg_ctx->GetRegisterInfoByName (ent->name);
|
||||
if (ri)
|
||||
ent->lldb_regno = ri->kinds[eRegisterKindLLDB];
|
||||
}
|
||||
|
||||
@@ -47,26 +47,22 @@ UnwindLLDB::AddFirstFrame ()
|
||||
// First, set up the 0th (initial) frame
|
||||
CursorSP first_cursor_sp(new Cursor ());
|
||||
RegisterContextSP no_frame;
|
||||
RegisterContextLLDB *first_register_ctx = new RegisterContextLLDB(m_thread, no_frame, first_cursor_sp->sctx, 0);
|
||||
if (!first_register_ctx->IsValid())
|
||||
{
|
||||
delete first_register_ctx;
|
||||
std::auto_ptr<RegisterContextLLDB> first_register_ctx_ap (new RegisterContextLLDB(m_thread, no_frame, first_cursor_sp->sctx, 0));
|
||||
if (first_register_ctx_ap.get() == NULL)
|
||||
return false;
|
||||
}
|
||||
if (!first_register_ctx->GetCFA (first_cursor_sp->cfa))
|
||||
{
|
||||
delete first_register_ctx;
|
||||
|
||||
if (!first_register_ctx_ap->IsValid())
|
||||
return false;
|
||||
}
|
||||
if (!first_register_ctx->GetPC (first_cursor_sp->start_pc))
|
||||
{
|
||||
delete first_register_ctx;
|
||||
|
||||
if (!first_register_ctx_ap->GetCFA (first_cursor_sp->cfa))
|
||||
return false;
|
||||
}
|
||||
// Reuse the StackFrame provided by the processor native machine context for the first frame
|
||||
first_register_ctx->SetStackFrame (m_thread.GetStackFrameAtIndex(0).get());
|
||||
RegisterContextSP first_register_ctx_sp(first_register_ctx);
|
||||
first_cursor_sp->reg_ctx = first_register_ctx_sp;
|
||||
|
||||
if (!first_register_ctx_ap->GetPC (first_cursor_sp->start_pc))
|
||||
return false;
|
||||
|
||||
// Everything checks out, so release the auto pointer value and let the
|
||||
// cursor own it in its shared pointer
|
||||
first_cursor_sp->reg_ctx.reset(first_register_ctx_ap.release());
|
||||
m_frames.push_back (first_cursor_sp);
|
||||
return true;
|
||||
}
|
||||
@@ -77,18 +73,21 @@ UnwindLLDB::AddOneMoreFrame ()
|
||||
{
|
||||
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
|
||||
CursorSP cursor_sp(new Cursor ());
|
||||
RegisterContextLLDB *register_ctx;
|
||||
|
||||
// Frame zero is a little different
|
||||
if (m_frames.size() == 0)
|
||||
return false;
|
||||
|
||||
uint32_t cur_idx = m_frames.size ();
|
||||
register_ctx = new RegisterContextLLDB (m_thread, m_frames[cur_idx - 1]->reg_ctx, cursor_sp->sctx, cur_idx);
|
||||
std::auto_ptr<RegisterContextLLDB> register_ctx_ap(new RegisterContextLLDB (m_thread,
|
||||
m_frames[cur_idx - 1]->reg_ctx,
|
||||
cursor_sp->sctx,
|
||||
cur_idx));
|
||||
if (register_ctx_ap.get() == NULL)
|
||||
return false;
|
||||
|
||||
if (!register_ctx->IsValid())
|
||||
if (!register_ctx_ap->IsValid())
|
||||
{
|
||||
delete register_ctx;
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d invalid RegisterContext for this frame, stopping stack walk",
|
||||
@@ -96,9 +95,8 @@ UnwindLLDB::AddOneMoreFrame ()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!register_ctx->GetCFA (cursor_sp->cfa))
|
||||
if (!register_ctx_ap->GetCFA (cursor_sp->cfa))
|
||||
{
|
||||
delete register_ctx;
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d did not get CFA for this frame, stopping stack walk",
|
||||
@@ -108,7 +106,6 @@ UnwindLLDB::AddOneMoreFrame ()
|
||||
}
|
||||
if (cursor_sp->cfa == (addr_t) -1 || cursor_sp->cfa == 1 || cursor_sp->cfa == 0)
|
||||
{
|
||||
delete register_ctx;
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk",
|
||||
@@ -116,9 +113,8 @@ UnwindLLDB::AddOneMoreFrame ()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!register_ctx->GetPC (cursor_sp->start_pc))
|
||||
if (!register_ctx_ap->GetPC (cursor_sp->start_pc))
|
||||
{
|
||||
delete register_ctx;
|
||||
if (log)
|
||||
{
|
||||
log->Printf("%*sFrame %d did not get PC for this frame, stopping stack walk",
|
||||
@@ -126,9 +122,7 @@ UnwindLLDB::AddOneMoreFrame ()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
RegisterContextSP register_ctx_sp(register_ctx);
|
||||
StackFrame *frame = new StackFrame(cur_idx, cur_idx, m_thread, register_ctx_sp, cursor_sp->cfa, cursor_sp->start_pc, &(cursor_sp->sctx));
|
||||
register_ctx->SetStackFrame (frame);
|
||||
RegisterContextSP register_ctx_sp(register_ctx_ap.release());
|
||||
cursor_sp->reg_ctx = register_ctx_sp;
|
||||
m_frames.push_back (cursor_sp);
|
||||
return true;
|
||||
@@ -155,9 +149,10 @@ UnwindLLDB::GetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr_t& pc)
|
||||
return false;
|
||||
}
|
||||
|
||||
RegisterContext *
|
||||
lldb::RegisterContextSP
|
||||
UnwindLLDB::CreateRegisterContextForFrame (StackFrame *frame)
|
||||
{
|
||||
lldb::RegisterContextSP reg_ctx_sp;
|
||||
uint32_t idx = frame->GetFrameIndex ();
|
||||
|
||||
if (idx == 0)
|
||||
@@ -168,13 +163,13 @@ UnwindLLDB::CreateRegisterContextForFrame (StackFrame *frame)
|
||||
if (m_frames.size() == 0)
|
||||
{
|
||||
if (!AddFirstFrame())
|
||||
return NULL;
|
||||
return reg_ctx_sp;
|
||||
}
|
||||
|
||||
while (idx >= m_frames.size() && AddOneMoreFrame ())
|
||||
;
|
||||
|
||||
if (idx < m_frames.size ())
|
||||
return m_frames[idx]->reg_ctx.get();
|
||||
return NULL;
|
||||
reg_ctx_sp = m_frames[idx]->reg_ctx;
|
||||
return reg_ctx_sp;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
lldb::addr_t& cfa,
|
||||
lldb::addr_t& start_pc);
|
||||
|
||||
lldb_private::RegisterContext *
|
||||
lldb::RegisterContextSP
|
||||
CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
|
||||
|
||||
private:
|
||||
|
||||
@@ -63,14 +63,15 @@ UnwindMacOSXFrameBackchain::GetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr
|
||||
return false;
|
||||
}
|
||||
|
||||
RegisterContext *
|
||||
lldb::RegisterContextSP
|
||||
UnwindMacOSXFrameBackchain::CreateRegisterContextForFrame (StackFrame *frame)
|
||||
{
|
||||
uint32_t idx = frame->GetUnwindFrameIndex ();
|
||||
lldb::RegisterContextSP reg_ctx_sp;
|
||||
uint32_t concrete_idx = frame->GetConcreteFrameIndex ();
|
||||
const uint32_t frame_count = GetFrameCount();
|
||||
if (idx < frame_count)
|
||||
return new RegisterContextMacOSXFrameBackchain (m_thread, frame, m_cursors[idx]);
|
||||
return NULL;
|
||||
if (concrete_idx < frame_count)
|
||||
reg_ctx_sp.reset (new RegisterContextMacOSXFrameBackchain (m_thread, concrete_idx, m_cursors[concrete_idx]));
|
||||
return reg_ctx_sp;
|
||||
}
|
||||
|
||||
size_t
|
||||
@@ -86,7 +87,7 @@ UnwindMacOSXFrameBackchain::GetStackFrameData_i386 (StackFrame *first_frame)
|
||||
uint32_t pc;
|
||||
};
|
||||
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
assert (reg_ctx);
|
||||
|
||||
Cursor cursor;
|
||||
@@ -174,7 +175,7 @@ UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64 (StackFrame *first_frame)
|
||||
uint64_t pc;
|
||||
};
|
||||
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
assert (reg_ctx);
|
||||
|
||||
Cursor cursor;
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
lldb::addr_t& cfa,
|
||||
lldb::addr_t& pc);
|
||||
|
||||
lldb_private::RegisterContext *
|
||||
lldb::RegisterContextSP
|
||||
CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
|
||||
|
||||
lldb_private::Thread &
|
||||
|
||||
@@ -32,11 +32,11 @@ using namespace lldb_private;
|
||||
GDBRemoteRegisterContext::GDBRemoteRegisterContext
|
||||
(
|
||||
ThreadGDBRemote &thread,
|
||||
StackFrame *frame,
|
||||
uint32_t concrete_frame_idx,
|
||||
GDBRemoteDynamicRegisterInfo ®_info,
|
||||
bool read_all_at_once
|
||||
) :
|
||||
RegisterContext (thread, frame),
|
||||
RegisterContext (thread, concrete_frame_idx),
|
||||
m_reg_info (reg_info),
|
||||
m_reg_valid (),
|
||||
m_reg_valid_stop_id (),
|
||||
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
// Constructors and Destructors
|
||||
//------------------------------------------------------------------
|
||||
GDBRemoteRegisterContext (ThreadGDBRemote &thread,
|
||||
lldb_private::StackFrame *frame,
|
||||
uint32_t concrete_frame_idx,
|
||||
GDBRemoteDynamicRegisterInfo ®_info,
|
||||
bool read_all_at_once);
|
||||
|
||||
|
||||
@@ -173,28 +173,29 @@ ThreadGDBRemote::ShouldStop (bool &step_more)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
RegisterContext *
|
||||
lldb::RegisterContextSP
|
||||
ThreadGDBRemote::GetRegisterContext ()
|
||||
{
|
||||
if (m_reg_context_sp.get() == NULL)
|
||||
m_reg_context_sp.reset (CreateRegisterContextForFrame (NULL));
|
||||
return m_reg_context_sp.get();
|
||||
m_reg_context_sp = CreateRegisterContextForFrame (NULL);
|
||||
return m_reg_context_sp;
|
||||
}
|
||||
|
||||
RegisterContext *
|
||||
lldb::RegisterContextSP
|
||||
ThreadGDBRemote::CreateRegisterContextForFrame (StackFrame *frame)
|
||||
{
|
||||
lldb::RegisterContextSP reg_ctx_sp;
|
||||
const bool read_all_registers_at_once = false;
|
||||
uint32_t frame_idx = 0;
|
||||
uint32_t concrete_frame_idx = 0;
|
||||
|
||||
if (frame)
|
||||
frame_idx = frame->GetFrameIndex ();
|
||||
concrete_frame_idx = frame->GetConcreteFrameIndex ();
|
||||
|
||||
if (frame_idx == 0)
|
||||
return new GDBRemoteRegisterContext (*this, frame, GetGDBProcess().m_register_info, read_all_registers_at_once);
|
||||
if (concrete_frame_idx == 0)
|
||||
reg_ctx_sp.reset (new GDBRemoteRegisterContext (*this, concrete_frame_idx, GetGDBProcess().m_register_info, read_all_registers_at_once));
|
||||
else if (m_unwinder_ap.get())
|
||||
return m_unwinder_ap->CreateRegisterContextForFrame (frame);
|
||||
return NULL;
|
||||
reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame (frame);
|
||||
return reg_ctx_sp;
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -41,10 +41,10 @@ public:
|
||||
virtual const char *
|
||||
GetQueueName ();
|
||||
|
||||
virtual lldb_private::RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
GetRegisterContext ();
|
||||
|
||||
virtual lldb_private::RegisterContext *
|
||||
virtual lldb::RegisterContextSP
|
||||
CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
|
||||
|
||||
virtual bool
|
||||
|
||||
@@ -135,17 +135,16 @@ UnwindPlan::Row::Clear ()
|
||||
void
|
||||
UnwindPlan::Row::Dump (Stream& s, int register_kind, Thread* thread) const
|
||||
{
|
||||
RegisterContext *rctx = NULL;
|
||||
RegisterContext *reg_ctx = NULL;
|
||||
const RegisterInfo *rinfo = NULL;
|
||||
int translated_regnum;
|
||||
if (thread && thread->GetRegisterContext())
|
||||
{
|
||||
rctx = thread->GetRegisterContext();
|
||||
}
|
||||
reg_ctx = thread->GetRegisterContext().get();
|
||||
|
||||
s.Printf ("offset %ld, CFA reg ", (long) GetOffset());
|
||||
if (rctx
|
||||
&& (translated_regnum = rctx->ConvertRegisterKindToRegisterNumber (register_kind, GetCFARegister())) != -1
|
||||
&& (rinfo = rctx->GetRegisterInfoAtIndex (translated_regnum)) != NULL
|
||||
if (reg_ctx
|
||||
&& (translated_regnum = reg_ctx->ConvertRegisterKindToRegisterNumber (register_kind, GetCFARegister())) != -1
|
||||
&& (rinfo = reg_ctx->GetRegisterInfoAtIndex (translated_regnum)) != NULL
|
||||
&& rinfo->name != NULL
|
||||
&& rinfo->name[0] != '\0')
|
||||
{
|
||||
@@ -160,11 +159,10 @@ UnwindPlan::Row::Dump (Stream& s, int register_kind, Thread* thread) const
|
||||
{
|
||||
s.Printf (" [");
|
||||
bool printed_name = false;
|
||||
if (thread && thread->GetRegisterContext())
|
||||
if (reg_ctx)
|
||||
{
|
||||
rctx = thread->GetRegisterContext();
|
||||
translated_regnum = rctx->ConvertRegisterKindToRegisterNumber (register_kind, idx->first);
|
||||
rinfo = rctx->GetRegisterInfoAtIndex (translated_regnum);
|
||||
translated_regnum = reg_ctx->ConvertRegisterKindToRegisterNumber (register_kind, idx->first);
|
||||
rinfo = reg_ctx->GetRegisterInfoAtIndex (translated_regnum);
|
||||
if (rinfo && rinfo->name)
|
||||
{
|
||||
s.Printf ("%s ", rinfo->name);
|
||||
|
||||
@@ -88,9 +88,9 @@ RegisterContext *
|
||||
ExecutionContext::GetRegisterContext () const
|
||||
{
|
||||
if (frame)
|
||||
return frame->GetRegisterContext();
|
||||
return frame->GetRegisterContext().get();
|
||||
else if (thread)
|
||||
return thread->GetRegisterContext();
|
||||
return thread->GetRegisterContext().get();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -2545,7 +2545,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
|
||||
}
|
||||
|
||||
ts.Printf("<");
|
||||
RegisterContext *register_context = thread->GetRegisterContext();
|
||||
RegisterContext *register_context = thread->GetRegisterContext().get();
|
||||
|
||||
if (register_context)
|
||||
ts.Printf("[ip 0x%llx] ", register_context->GetPC());
|
||||
|
||||
@@ -21,18 +21,9 @@
|
||||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// RegisterContext constructors
|
||||
//----------------------------------------------------------------------
|
||||
RegisterContext::RegisterContext (Thread &thread, StackFrame *frame) :
|
||||
RegisterContext::RegisterContext (Thread &thread, uint32_t concrete_frame_idx) :
|
||||
m_thread (thread),
|
||||
m_frame (frame)
|
||||
{
|
||||
}
|
||||
|
||||
RegisterContext::RegisterContext (Thread &thread) :
|
||||
m_thread (thread),
|
||||
m_frame (NULL)
|
||||
m_concrete_frame_idx (concrete_frame_idx)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -86,8 +77,9 @@ RegisterContext::SetPC(uint64_t pc)
|
||||
bool success = WriteRegisterFromUnsigned (reg, pc);
|
||||
if (success)
|
||||
{
|
||||
if (m_frame)
|
||||
m_frame->ChangePC(pc);
|
||||
StackFrameSP frame_sp(m_thread.GetFrameWithConcreteFrameIndex (m_concrete_frame_idx));
|
||||
if (frame_sp)
|
||||
frame_sp->ChangePC(pc);
|
||||
else
|
||||
m_thread.ClearStackFrames ();
|
||||
}
|
||||
@@ -207,12 +199,6 @@ RegisterContext::HardwareSingleStep (bool enable)
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
RegisterContext::SetStackFrame (StackFrame *frame)
|
||||
{
|
||||
m_frame = frame;
|
||||
}
|
||||
|
||||
Target *
|
||||
RegisterContext::CalculateTarget ()
|
||||
{
|
||||
@@ -235,16 +221,16 @@ RegisterContext::CalculateThread ()
|
||||
StackFrame *
|
||||
RegisterContext::CalculateStackFrame ()
|
||||
{
|
||||
return m_frame;
|
||||
// Register contexts might belong to many frames if we have inlined
|
||||
// functions inside a frame since all inlined functions share the
|
||||
// same registers, so we can't definitively say which frame we come from...
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
RegisterContext::CalculateExecutionContext (ExecutionContext &exe_ctx)
|
||||
{
|
||||
if (m_frame)
|
||||
m_frame->CalculateExecutionContext (exe_ctx);
|
||||
else
|
||||
m_thread.CalculateExecutionContext (exe_ctx);
|
||||
m_thread.CalculateExecutionContext (exe_ctx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ StackFrame::StackFrame
|
||||
const SymbolContext *sc_ptr
|
||||
) :
|
||||
m_frame_index (frame_idx),
|
||||
m_unwind_frame_index (unwind_frame_index),
|
||||
m_concrete_frame_index (unwind_frame_index),
|
||||
m_thread (thread),
|
||||
m_reg_context_sp (),
|
||||
m_id (pc, cfa, NULL),
|
||||
@@ -79,7 +79,7 @@ StackFrame::StackFrame
|
||||
const SymbolContext *sc_ptr
|
||||
) :
|
||||
m_frame_index (frame_idx),
|
||||
m_unwind_frame_index (unwind_frame_index),
|
||||
m_concrete_frame_index (unwind_frame_index),
|
||||
m_thread (thread),
|
||||
m_reg_context_sp (reg_context_sp),
|
||||
m_id (pc, cfa, NULL),
|
||||
@@ -115,7 +115,7 @@ StackFrame::StackFrame
|
||||
const SymbolContext *sc_ptr
|
||||
) :
|
||||
m_frame_index (frame_idx),
|
||||
m_unwind_frame_index (unwind_frame_index),
|
||||
m_concrete_frame_index (unwind_frame_index),
|
||||
m_thread (thread),
|
||||
m_reg_context_sp (reg_context_sp),
|
||||
m_id (pc_addr.GetLoadAddress (&thread.GetProcess().GetTarget()), cfa, NULL),
|
||||
@@ -755,12 +755,12 @@ StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr)
|
||||
return m_frame_base_error.Success();
|
||||
}
|
||||
|
||||
RegisterContext *
|
||||
RegisterContextSP
|
||||
StackFrame::GetRegisterContext ()
|
||||
{
|
||||
if (m_reg_context_sp.get() == NULL)
|
||||
m_reg_context_sp.reset (m_thread.CreateRegisterContextForFrame (this));
|
||||
return m_reg_context_sp.get();
|
||||
if (!m_reg_context_sp)
|
||||
m_reg_context_sp = m_thread.CreateRegisterContextForFrame (this);
|
||||
return m_reg_context_sp;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -916,7 +916,7 @@ StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame)
|
||||
m_id.SetPC (curr_frame.m_id.GetPC()); // Update the Stack ID PC value
|
||||
assert (&m_thread == &curr_frame.m_thread);
|
||||
m_frame_index = curr_frame.m_frame_index;
|
||||
m_unwind_frame_index = curr_frame.m_unwind_frame_index;
|
||||
m_concrete_frame_index = curr_frame.m_concrete_frame_index;
|
||||
m_reg_context_sp = curr_frame.m_reg_context_sp;
|
||||
m_frame_code_addr = curr_frame.m_frame_code_addr;
|
||||
assert (m_sc.target_sp.get() == NULL || curr_frame.m_sc.target_sp.get() == NULL || m_sc.target_sp.get() == curr_frame.m_sc.target_sp.get());
|
||||
|
||||
@@ -336,6 +336,27 @@ StackFrameList::GetFrameAtIndex (uint32_t idx)
|
||||
return frame_sp;
|
||||
}
|
||||
|
||||
StackFrameSP
|
||||
StackFrameList::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
|
||||
{
|
||||
// First try assuming the unwind index is the same as the frame index. The
|
||||
// unwind index is always greater than or equal to the frame index, so it
|
||||
// is a good place to start. If we have inlined frames we might have 5
|
||||
// concrete frames (frame unwind indexes go from 0-4), but we might have 15
|
||||
// frames after we make all the inlined frames. Most of the time the unwind
|
||||
// frame index (or the concrete frame index) is the same as the frame index.
|
||||
uint32_t frame_idx = unwind_idx;
|
||||
StackFrameSP frame_sp (GetFrameAtIndex (frame_idx));
|
||||
while (frame_sp)
|
||||
{
|
||||
if (frame_sp->GetFrameIndex() == unwind_idx)
|
||||
break;
|
||||
frame_sp = GetFrameAtIndex (++frame_idx);
|
||||
}
|
||||
return frame_sp;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
StackFrameList::SetFrameAtIndex (uint32_t idx, StackFrameSP &frame_sp)
|
||||
{
|
||||
|
||||
@@ -877,6 +877,13 @@ Thread::GetSelectedFrameIndex ()
|
||||
return GetStackFrameList().GetSelectedFrameIndex();
|
||||
}
|
||||
|
||||
lldb::StackFrameSP
|
||||
Thread::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
|
||||
{
|
||||
return GetStackFrameList().GetFrameWithConcreteFrameIndex (unwind_idx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
lldb::StackFrameSP
|
||||
Thread::GetSelectedFrame ()
|
||||
|
||||
@@ -149,7 +149,7 @@ ThreadPlan::WillResume (StateType resume_state, bool current_plan)
|
||||
|
||||
if (log)
|
||||
{
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
addr_t pc = reg_ctx->GetPC();
|
||||
addr_t sp = reg_ctx->GetSP();
|
||||
addr_t fp = reg_ctx->GetFP();
|
||||
|
||||
@@ -95,7 +95,7 @@ ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
|
||||
|
||||
if (log)
|
||||
{
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
|
||||
log->PutCString("Function call was set up. Register state was:");
|
||||
|
||||
@@ -214,7 +214,7 @@ ThreadPlanCallFunction::ShouldStop (Event *event_ptr)
|
||||
|
||||
if (log)
|
||||
{
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
|
||||
log->PutCString("Function completed. Register state was:");
|
||||
|
||||
|
||||
@@ -132,9 +132,10 @@ ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer()
|
||||
{
|
||||
}
|
||||
|
||||
void ThreadPlanAssemblyTracer::TracingStarted ()
|
||||
void
|
||||
ThreadPlanAssemblyTracer::TracingStarted ()
|
||||
{
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
|
||||
if (m_register_values.size() == 0)
|
||||
{
|
||||
@@ -145,7 +146,8 @@ void ThreadPlanAssemblyTracer::TracingStarted ()
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadPlanAssemblyTracer::TracingEnded ()
|
||||
void
|
||||
ThreadPlanAssemblyTracer::TracingEnded ()
|
||||
{
|
||||
for (uint32_t reg_index = 0, num_registers = m_register_values.size();
|
||||
reg_index < num_registers;
|
||||
@@ -153,51 +155,26 @@ void ThreadPlanAssemblyTracer::TracingEnded ()
|
||||
m_register_values[reg_index] = 0;
|
||||
}
|
||||
|
||||
static const char *Padding(int length)
|
||||
{
|
||||
const int padding_size = 256;
|
||||
|
||||
static char* padding = NULL;
|
||||
static int prev_length = 256;
|
||||
|
||||
if (!padding) {
|
||||
padding = new char[padding_size];
|
||||
memset(padding, ' ', padding_size);
|
||||
}
|
||||
|
||||
if (length > 255)
|
||||
length = 255;
|
||||
|
||||
if (prev_length < 256)
|
||||
padding[prev_length] = ' ';
|
||||
|
||||
padding[length] = '\0';
|
||||
|
||||
prev_length = length;
|
||||
|
||||
return padding;
|
||||
}
|
||||
|
||||
static void PadOutTo(StreamString &stream, int target)
|
||||
static void
|
||||
PadOutTo (StreamString &stream, int target)
|
||||
{
|
||||
stream.Flush();
|
||||
|
||||
int length = stream.GetString().length();
|
||||
|
||||
if (length + 1 < target)
|
||||
stream.PutCString(Padding(target - (length + 1)));
|
||||
|
||||
stream.PutCString(" ");
|
||||
stream.Printf("%*s", target - (length + 1) + 1, "");
|
||||
}
|
||||
|
||||
void ThreadPlanAssemblyTracer::Log ()
|
||||
void
|
||||
ThreadPlanAssemblyTracer::Log ()
|
||||
{
|
||||
Stream *stream = GetLogStream ();
|
||||
|
||||
if (!stream)
|
||||
return;
|
||||
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext();
|
||||
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
|
||||
|
||||
lldb::addr_t pc = reg_ctx->GetPC();
|
||||
Address pc_addr;
|
||||
|
||||
Reference in New Issue
Block a user