First try at patching linux for the recent RegisterContext patch. Can someone

try and build this and let me know how it goes?

llvm-svn: 122981
This commit is contained in:
Greg Clayton 2011-01-06 22:35:55 +00:00
parent c07c98f853
commit 43b4e213cb
5 changed files with 52 additions and 34 deletions

View File

@ -26,21 +26,8 @@ using namespace lldb_private;
LinuxThread::LinuxThread(Process &process, lldb::tid_t tid)
: Thread(process, tid),
m_frame_ap(0),
m_register_ap(0),
m_note(eNone)
{
ArchSpec arch = process.GetTarget().GetArchitecture();
switch (arch.GetGenericCPUType())
{
default:
assert(false && "CPU type not supported!");
break;
case ArchSpec::eCPU_x86_64:
m_register_ap.reset(new RegisterContextLinux_x86_64(*this, NULL));
break;
}
}
ProcessMonitor &
@ -61,10 +48,25 @@ LinuxThread::GetInfo()
return NULL;
}
RegisterContextLinux *
lldb::RegisterContextSP
LinuxThread::GetRegisterContext()
{
return m_register_ap.get();
if (!m_reg_context_sp)
{
ArchSpec arch = process.GetTarget().GetArchitecture();
switch (arch.GetGenericCPUType())
{
default:
assert(false && "CPU type not supported!");
break;
case ArchSpec::eCPU_x86_64:
m_reg_context_sp.reset(new RegisterContextLinux_x86_64(*this, 0));
break;
}
}
return m_reg_context_sp
}
bool
@ -79,10 +81,19 @@ LinuxThread::RestoreSaveFrameZero(const RegisterCheckpoint &checkpoint)
return false;
}
RegisterContextLinux *
LinuxThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame)
lldb::RegisterContextSP
LinuxThread::CreateRegisterContextForFrame (lldb_private::StackFrame *frame)
{
return new RegisterContextLinux_x86_64(*this, frame);
lldb::RegisterContextSP reg_ctx_sp;
uint32_t concrete_frame_idx = 0;
if (frame)
concrete_frame_idx = frame->GetConcreteFrameIndex();
if (concrete_frame_idx == 0)
reg_ctx_sp = GetRegisterContext();
else
reg_ctx_sp.reset (new RegisterContextLinux_x86_64(*this, frame->GetConcreteFrameIndex()));
return reg_ctx_sp;
}
lldb::StopInfoSP
@ -159,14 +170,13 @@ LinuxThread::BreakNotify()
{
bool status;
status = GetRegisterContext()->UpdateAfterBreakpoint();
status = GetRegisterContextLinux()->UpdateAfterBreakpoint();
assert(status && "Breakpoint update failed!");
// With our register state restored, resolve the breakpoint object
// corresponding to our current PC.
lldb::addr_t pc = GetRegisterContext()->GetPC();
lldb::BreakpointSiteSP bp_site =
GetProcess().GetBreakpointSiteList().FindByAddress(pc);
lldb::BreakpointSiteSP bp_site(GetProcess().GetBreakpointSiteList().FindByAddress(pc));
assert(bp_site && bp_site->ValidForThisThread(this));
m_note = eBreak;

View File

@ -16,9 +16,9 @@
// Other libraries and framework includes
#include "lldb/Target/Thread.h"
#include "RegisterContextLinux.h"
class ProcessMonitor;
class RegisterContextLinux;
//------------------------------------------------------------------------------
// @class LinuxThread
@ -38,17 +38,17 @@ public:
const char *
GetInfo();
RegisterContextLinux *
virtual lldb::RegisterContextSP
GetRegisterContext();
bool
virtual bool
SaveFrameZeroState(RegisterCheckpoint &checkpoint);
bool
virtual bool
RestoreSaveFrameZero(const RegisterCheckpoint &checkpoint);
RegisterContextLinux *
CreateRegisterContextForFrame(lldb_private::StackFrame *frame);
virtual lldb::RegisterContextSP
CreateRegisterContextForFrame (StackFrame *frame);
//--------------------------------------------------------------------------
// These methods form a specialized interface to linux threads.
@ -60,8 +60,16 @@ public:
void ExitNotify();
private:
RegisterContextLinux *
GetRegisterContextLinux ()
{
if (!m_reg_context_sp)
GetRegisterContext();
return (RegisterContextLinux *)m_reg_context_sp.get()
}
std::auto_ptr<lldb_private::StackFrame> m_frame_ap;
std::auto_ptr<RegisterContextLinux> m_register_ap;
lldb::BreakpointSiteSP m_breakpoint;

View File

@ -24,8 +24,8 @@ class RegisterContextLinux
{
public:
RegisterContextLinux(lldb_private::Thread &thread,
lldb_private::StackFrame *frame)
: RegisterContext(thread, frame) { }
uint32_t concrete_frame_idx)
: RegisterContext(thread, concrete_frame_idx) { }
/// Updates the register state of the associated thread after hitting a
/// breakpoint (if that make sense for the architecture). Default

View File

@ -402,8 +402,8 @@ static unsigned GetRegOffset(unsigned reg)
}
RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(Thread &thread,
StackFrame *frame)
: RegisterContextLinux(thread, frame)
uint32_t concrete_frame_idx)
: RegisterContextLinux(thread, concrete_frame_idx)
{
}

View File

@ -18,8 +18,8 @@ class RegisterContextLinux_x86_64
: public RegisterContextLinux
{
public:
RegisterContextLinux_x86_64(lldb_private::Thread &thread,
lldb_private::StackFrame *frame);
RegisterContextLinux_x86_64 (lldb_private::Thread &thread,
uint32_t concrete_frame_idx);
~RegisterContextLinux_x86_64();