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
diff --git a/lldb/source/Plugins/Process/Linux/LinuxThread.cpp b/lldb/source/Plugins/Process/Linux/LinuxThread.cpp
index c4c8bf5..725cc5a 100644
--- a/lldb/source/Plugins/Process/Linux/LinuxThread.cpp
+++ b/lldb/source/Plugins/Process/Linux/LinuxThread.cpp
@@ -26,21 +26,8 @@
 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 @@
     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 @@
     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 @@
 {
     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;
diff --git a/lldb/source/Plugins/Process/Linux/LinuxThread.h b/lldb/source/Plugins/Process/Linux/LinuxThread.h
index 0e7f89d..a87e5ca 100644
--- a/lldb/source/Plugins/Process/Linux/LinuxThread.h
+++ b/lldb/source/Plugins/Process/Linux/LinuxThread.h
@@ -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 @@
     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 @@
     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;
 
diff --git a/lldb/source/Plugins/Process/Linux/RegisterContextLinux.h b/lldb/source/Plugins/Process/Linux/RegisterContextLinux.h
index 4badd4b..519c06a 100644
--- a/lldb/source/Plugins/Process/Linux/RegisterContextLinux.h
+++ b/lldb/source/Plugins/Process/Linux/RegisterContextLinux.h
@@ -24,8 +24,8 @@
 {
 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
diff --git a/lldb/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
index 4c78a25..10d9947 100644
--- a/lldb/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
@@ -402,8 +402,8 @@
 }
 
 RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(Thread &thread,
-                                                         StackFrame *frame)
-    : RegisterContextLinux(thread, frame)
+                                                         uint32_t concrete_frame_idx)
+    : RegisterContextLinux(thread, concrete_frame_idx)
 {
 }
 
diff --git a/lldb/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h b/lldb/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h
index b61de40..9bba38a 100644
--- a/lldb/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h
+++ b/lldb/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h
@@ -18,8 +18,8 @@
     : 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();