[Lldb-commits] [PATCH 4/4] Fix API changes in PlatformLinux and RegisterContext.

Marco Minutoli mminutoli at gmail.com
Thu May 12 14:39:30 PDT 2011


This patch add a "fake" attach waiting for a real implementation and
solve the build break due to the lack of this method.

It also propose a solution to the API changes in RegisterContext.

I upgraded also the the python version in the makefile. My linux
installation has python2.7 and AFAIK also the latest ubuntu
has this version of python so maybe is worth upgrading.

---
 Makefile                                           |    2 +-
 source/Plugins/Platform/Linux/PlatformLinux.cpp    |   14 ++++++++++-
 source/Plugins/Platform/Linux/PlatformLinux.h      |    6 ++++-
 source/Plugins/Process/Linux/ProcessMonitor.cpp    |   15 ++++++-----
 source/Plugins/Process/Linux/ProcessMonitor.h      |    4 +-
 .../Process/Linux/RegisterContextLinux_i386.cpp    |   25 +++++++++++++++++++-
 .../Process/Linux/RegisterContextLinux_i386.h      |   12 +++++++++
 .../Process/Linux/RegisterContextLinux_x86_64.cpp  |    5 ++++
 .../Process/Linux/RegisterContextLinux_x86_64.h    |   12 +++++++++
 9 files changed, 82 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index a84e244..4357ccc 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ LEVEL := $(LLDB_LEVEL)/../..
 include $(LEVEL)/Makefile.common
 
 # Set Python include directory
-PYTHON_INC_DIR = /usr/include/python2.6
+PYTHON_INC_DIR = /usr/include/python2.7/
 
 # Set common LLDB build flags.
 CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include 
diff --git a/source/Plugins/Platform/Linux/PlatformLinux.cpp b/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 379a08e..f37a312 100644
--- a/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -192,7 +192,7 @@ PlatformLinux::~PlatformLinux()
 }
 
 bool
-PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info)
+PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
 {
     return Host::GetProcessInfo (pid, process_info);
 }
@@ -247,3 +247,15 @@ PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target,
     bp_site->SetTrapOpcode(opcode, opcode_size);
     return opcode_size;
 }
+
+lldb::ProcessSP
+PlatformLinux::Attach(lldb::pid_t pid,
+                      Debugger &debugger,
+                      Target *target,
+                      Listener &listener,
+                      Error &error)
+{
+    ProcessSP processSP;
+    assert(!"Not implemented yet!");
+    return processSP;
+}
diff --git a/source/Plugins/Platform/Linux/PlatformLinux.h b/source/Plugins/Platform/Linux/PlatformLinux.h
index bb9f62c..cbe18eb 100644
--- a/source/Plugins/Platform/Linux/PlatformLinux.h
+++ b/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -85,7 +85,7 @@ namespace lldb_private {
                  const UUID* uuid, FileSpec &local_file);
 
         virtual bool
-        GetProcessInfo (lldb::pid_t pid, ProcessInfo &proc_info);
+        GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info);
 
         virtual bool
         GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch);
@@ -94,6 +94,10 @@ namespace lldb_private {
         GetSoftwareBreakpointTrapOpcode (Target &target, 
                                          BreakpointSite *bp_site);
 
+        virtual lldb::ProcessSP
+        Attach(lldb::pid_t pid, Debugger &debugger, Target *target,
+               Listener &listener, Error &error);
+
     protected:
         
         
diff --git a/source/Plugins/Process/Linux/ProcessMonitor.cpp b/source/Plugins/Process/Linux/ProcessMonitor.cpp
index 48a57a8..f482c01 100644
--- a/source/Plugins/Process/Linux/ProcessMonitor.cpp
+++ b/source/Plugins/Process/Linux/ProcessMonitor.cpp
@@ -20,6 +20,7 @@
 // C++ Includes
 // Other libraries and framework includes
 #include "lldb/Core/Error.h"
+#include "lldb/Core/RegisterValue.h"
 #include "lldb/Core/Scalar.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Target/Thread.h"
@@ -221,7 +222,7 @@ WriteOperation::Execute(ProcessMonitor *monitor)
 class ReadRegOperation : public Operation
 {
 public:
-    ReadRegOperation(unsigned offset, Scalar &value, bool &result)
+    ReadRegOperation(unsigned offset, RegisterValue &value, bool &result)
         : m_offset(offset), m_value(value), m_result(result)
         { }
 
@@ -229,7 +230,7 @@ public:
 
 private:
     unsigned m_offset;
-    Scalar &m_value;
+    RegisterValue &m_value;
     bool &m_result;
 };
 
@@ -257,7 +258,7 @@ ReadRegOperation::Execute(ProcessMonitor *monitor)
 class WriteRegOperation : public Operation
 {
 public:
-    WriteRegOperation(unsigned offset, const Scalar &value, bool &result)
+    WriteRegOperation(unsigned offset, const RegisterValue &value, bool &result)
         : m_offset(offset), m_value(value), m_result(result)
         { }
 
@@ -265,7 +266,7 @@ public:
 
 private:
     unsigned m_offset;
-    const Scalar &m_value;
+    const RegisterValue &m_value;
     bool &m_result;
 };
 
@@ -274,7 +275,7 @@ WriteRegOperation::Execute(ProcessMonitor *monitor)
 {
     lldb::pid_t pid = monitor->GetPID();
 
-    if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.ULong()))
+    if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.GetAsUInt64()))
         m_result = false;
     else
         m_result = true;
@@ -1097,7 +1098,7 @@ ProcessMonitor::WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
 }
 
 bool
-ProcessMonitor::ReadRegisterValue(unsigned offset, Scalar &value)
+ProcessMonitor::ReadRegisterValue(unsigned offset, RegisterValue &value)
 {
     bool result;
     ReadRegOperation op(offset, value, result);
@@ -1106,7 +1107,7 @@ ProcessMonitor::ReadRegisterValue(unsigned offset, Scalar &value)
 }
 
 bool
-ProcessMonitor::WriteRegisterValue(unsigned offset, const Scalar &value)
+ProcessMonitor::WriteRegisterValue(unsigned offset, const RegisterValue &value)
 {
     bool result;
     WriteRegOperation op(offset, value, result);
diff --git a/source/Plugins/Process/Linux/ProcessMonitor.h b/source/Plugins/Process/Linux/ProcessMonitor.h
index 1bfdb86..0f2f61c 100644
--- a/source/Plugins/Process/Linux/ProcessMonitor.h
+++ b/source/Plugins/Process/Linux/ProcessMonitor.h
@@ -100,14 +100,14 @@ public:
     ///
     /// This method is provided for use by RegisterContextLinux derivatives.
     bool
-    ReadRegisterValue(unsigned offset, lldb_private::Scalar &value);
+    ReadRegisterValue(unsigned offset, lldb_private::RegisterValue &value);
 
     /// Writes the given value to the register identified by the given
     /// (architecture dependent) offset.
     ///
     /// This method is provided for use by RegisterContextLinux derivatives.
     bool
-    WriteRegisterValue(unsigned offset, const lldb_private::Scalar &value);
+    WriteRegisterValue(unsigned offset, const lldb_private::RegisterValue &value);
 
     /// Reads all general purpose registers into the specified buffer.
     bool
diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp b/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp
index 6bee0c9..0a8ec5a 100644
--- a/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp
+++ b/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextLinux_i386.cpp ----------------------------*- C++ -*-===//
+//===-- RegisterContextLinux_i386.cpp ---------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -411,6 +411,17 @@ RegisterContextLinux_i386::GetRegisterSet(uint32_t set)
 }
 
 bool
+RegisterContextLinux_i386::ReadRegister(const RegisterInfo *reg_info,
+                                        RegisterValue &value)
+{
+    const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+    ProcessMonitor &monitor = GetMonitor();
+    return monitor.ReadRegisterValue(GetRegOffset(reg), value);
+}
+
+#if 0
+
+bool
 RegisterContextLinux_i386::ReadRegisterValue(uint32_t reg,
                                                Scalar &value)
 {
@@ -441,12 +452,16 @@ RegisterContextLinux_i386::ReadRegisterBytes(uint32_t reg,
     return status;
 }
 
+#endif
+
 bool
 RegisterContextLinux_i386::ReadAllRegisterValues(DataBufferSP &data_sp)
 {
     return false;
 }
 
+#if 0
+
 bool
 RegisterContextLinux_i386::WriteRegisterValue(uint32_t reg,
                                               const Scalar &value)
@@ -463,6 +478,14 @@ RegisterContextLinux_i386::WriteRegisterBytes(uint32_t reg,
     return false;
 }
 
+#endif
+
+bool RegisterContextLinux_i386::WriteRegister(const RegisterInfo *reg_info,
+                                              const RegisterValue &value)
+{
+    return false;
+}
+
 bool
 RegisterContextLinux_i386::WriteAllRegisterValues(const DataBufferSP &data)
 {
diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_i386.h b/source/Plugins/Process/Linux/RegisterContextLinux_i386.h
index 890fd88..ef3a76b 100644
--- a/source/Plugins/Process/Linux/RegisterContextLinux_i386.h
+++ b/source/Plugins/Process/Linux/RegisterContextLinux_i386.h
@@ -42,21 +42,33 @@ public:
     const lldb_private::RegisterSet *
     GetRegisterSet(uint32_t set);
 
+#if 0
     bool
     ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value);
 
     bool
     ReadRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data);
+#endif
+
+    virtual bool
+    ReadRegister(const lldb_private::RegisterInfo *reg_info,
+                 lldb_private::RegisterValue &value);
 
     bool
     ReadAllRegisterValues(lldb::DataBufferSP &data_sp);
 
+#if 0
     bool
     WriteRegisterValue(uint32_t reg, const lldb_private::Scalar &value);
 
     bool
     WriteRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data,
                        uint32_t data_offset = 0);
+#endif
+
+    virtual bool
+    WriteRegister(const lldb_private::RegisterInfo *reg_info,
+                  const lldb_private::RegisterValue &value);
 
     bool
     WriteAllRegisterValues(const lldb::DataBufferSP &data_sp);
diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
index 27ca5b8..012690f 100644
--- a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
+++ b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp
@@ -475,6 +475,7 @@ RegisterContextLinux_x86_64::GetRegisterSet(uint32_t set)
         return NULL;
 }
 
+#if 0
 bool
 RegisterContextLinux_x86_64::ReadRegisterValue(uint32_t reg,
                                                Scalar &value)
@@ -506,12 +507,15 @@ RegisterContextLinux_x86_64::ReadRegisterBytes(uint32_t reg,
     return status;
 }
 
+#endif
+
 bool
 RegisterContextLinux_x86_64::ReadAllRegisterValues(DataBufferSP &data_sp)
 {
     return false;
 }
 
+#if 0
 bool
 RegisterContextLinux_x86_64::WriteRegisterValue(uint32_t reg,
                                                 const Scalar &value)
@@ -527,6 +531,7 @@ RegisterContextLinux_x86_64::WriteRegisterBytes(uint32_t reg,
 {
     return false;
 }
+#endif
 
 bool
 RegisterContextLinux_x86_64::WriteAllRegisterValues(const DataBufferSP &data)
diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h
index 48540b4..2d210c6 100644
--- a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h
+++ b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h
@@ -41,21 +41,33 @@ public:
     const lldb_private::RegisterSet *
     GetRegisterSet(uint32_t set);
 
+#if 0
     bool
     ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value);
 
     bool
     ReadRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data);
+#endif
+
+    virtual bool
+    ReadRegister(const lldb_private::RegisterInfo *reg_info,
+                 lldb_private::RegisterValue &value);
 
     bool
     ReadAllRegisterValues(lldb::DataBufferSP &data_sp);
 
+#if 0
     bool
     WriteRegisterValue(uint32_t reg, const lldb_private::Scalar &value);
 
     bool
     WriteRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data,
                        uint32_t data_offset = 0);
+#endif
+
+    virtual bool
+    WriteRegister(const lldb_private::RegisterInfo *reg_info,
+                  const lldb_private::RegisterValue &value);
 
     bool
     WriteAllRegisterValues(const lldb::DataBufferSP &data_sp);
-- 
1.7.3.4




More information about the lldb-commits mailing list