[Lldb-commits] [lldb] r122981 - in /lldb/trunk/source/Plugins/Process/Linux: LinuxThread.cpp LinuxThread.h RegisterContextLinux.h RegisterContextLinux_x86_64.cpp RegisterContextLinux_x86_64.h

Greg Clayton gclayton at apple.com
Thu Jan 6 14:35:55 PST 2011


Author: gclayton
Date: Thu Jan  6 16:35:55 2011
New Revision: 122981

URL: http://llvm.org/viewvc/llvm-project?rev=122981&view=rev
Log:
First try at patching linux for the recent RegisterContext patch. Can someone
try and build this and let me know how it goes?


Modified:
    lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp
    lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h
    lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux.h
    lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
    lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h

Modified: lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp?rev=122981&r1=122980&r2=122981&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp Thu Jan  6 16:35:55 2011
@@ -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;

Modified: lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h?rev=122981&r1=122980&r2=122981&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h Thu Jan  6 16:35:55 2011
@@ -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;
 

Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux.h?rev=122981&r1=122980&r2=122981&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux.h Thu Jan  6 16:35:55 2011
@@ -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

Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp?rev=122981&r1=122980&r2=122981&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp Thu Jan  6 16:35:55 2011
@@ -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)
 {
 }
 

Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h?rev=122981&r1=122980&r2=122981&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h Thu Jan  6 16:35:55 2011
@@ -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();
 





More information about the lldb-commits mailing list