From c6672c8783d3fb086c55b0827e81eaf1bac93f3d Mon Sep 17 00:00:00 2001 From: Matt Kopec Date: Fri, 15 Mar 2013 20:00:39 +0000 Subject: [PATCH] Rollback r177173. Some OSs may not have ptrace extensions which lldb expects when building. This needs to be accounted for. llvm-svn: 177176 --- .../Plugins/Process/FreeBSD/ProcessMonitor.cpp | 86 +------------------- .../Plugins/Process/FreeBSD/ProcessMonitor.h | 16 +--- .../Plugins/Process/Linux/ProcessMonitor.cpp | 94 +--------------------- lldb/source/Plugins/Process/Linux/ProcessMonitor.h | 14 +--- 4 files changed, 9 insertions(+), 201 deletions(-) diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp index f58fe00..724086b 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp @@ -82,10 +82,7 @@ PtraceWrapper(int req, ::pid_t pid, void *addr, int data, //PtraceDisplayBytes(req, data); errno = 0; - if (req == PTRACE_GETREGSET || req == PTRACE_SETREGSET) - result = ptrace(req, pid, *(unsigned int *)addr, data); - else - result = ptrace(req, pid, (caddr_t) addr, data); + result = ptrace(req, pid, (caddr_t) addr, data); //PtraceDisplayBytes(req, data); @@ -124,10 +121,7 @@ PtraceWrapper(__ptrace_request req, pid_t pid, void *addr, void *data) { long result = 0; errno = 0; - if (req == PTRACE_GETREGSET || req == PTRACE_SETREGSET) - result = ptrace(req, pid, *(unsigned int *)addr, data); - else - result = ptrace(req, pid, addr, data); + result = ptrace(req, pid, addr, data); return result; } @@ -402,35 +396,6 @@ ReadFPROperation::Execute(ProcessMonitor *monitor) } //------------------------------------------------------------------------------ -/// @class ReadRegisterSetOperation -/// @brief Implements ProcessMonitor::ReadRegisterSet. -class ReadRegisterSetOperation : public Operation -{ -public: - ReadRegisterSetOperation(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset, bool &result) - : m_tid(tid), m_buf(buf), m_buf_size(buf_size), m_regset(regset), m_result(result) - { } - - void Execute(ProcessMonitor *monitor); - -private: - lldb::tid_t m_tid; - void *m_buf; - size_t m_buf_size; - const unsigned int m_regset; - bool &m_result; -}; - -void -ReadRegisterSetOperation::Execute(ProcessMonitor *monitor) -{ - if (PTRACE(PTRACE_GETREGSET, m_tid, (void *)&m_regset, m_buf) < 0) - m_result = false; - else - m_result = true; -} - -//------------------------------------------------------------------------------ /// @class WriteGPROperation /// @brief Implements ProcessMonitor::WriteGPR. class WriteGPROperation : public Operation @@ -483,35 +448,6 @@ WriteFPROperation::Execute(ProcessMonitor *monitor) } //------------------------------------------------------------------------------ -/// @class WriteRegisterSetOperation -/// @brief Implements ProcessMonitor::WriteRegisterSet. -class WriteRegisterSetOperation : public Operation -{ -public: - WriteRegisterSetOperation(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset, bool &result) - : m_tid(tid), m_buf(buf), m_buf_size(buf_size), m_regset(regset), m_result(result) - { } - - void Execute(ProcessMonitor *monitor); - -private: - lldb::tid_t m_tid; - void *m_buf; - size_t m_buf_size; - const unsigned int m_regset; - bool &m_result; -}; - -void -WriteRegisterSetOperation::Execute(ProcessMonitor *monitor) -{ - if (PTRACE(PTRACE_SETREGSET, m_tid, (void *)&m_regset, m_buf) < 0) - m_result = false; - else - m_result = true; -} - -//------------------------------------------------------------------------------ /// @class ResumeOperation /// @brief Implements ProcessMonitor::Resume. class ResumeOperation : public Operation @@ -1539,15 +1475,6 @@ ProcessMonitor::ReadFPR(lldb::tid_t tid, void *buf, size_t buf_size) } bool -ProcessMonitor::ReadRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset) -{ - bool result; - ReadRegisterSetOperation op(tid, buf, buf_size, regset, result); - DoOperation(&op); - return result; -} - -bool ProcessMonitor::WriteGPR(lldb::tid_t tid, void *buf, size_t buf_size) { bool result; @@ -1566,15 +1493,6 @@ ProcessMonitor::WriteFPR(lldb::tid_t tid, void *buf, size_t buf_size) } bool -ProcessMonitor::WriteRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset) -{ - bool result; - WriteRegisterSetOperation op(tid, buf, buf_size, regset, result); - DoOperation(&op); - return result; -} - -bool ProcessMonitor::Resume(lldb::tid_t tid, uint32_t signo) { bool result; diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h index d677dd4..bc0fbdf 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h @@ -126,33 +126,23 @@ public: bool ReadGPR(lldb::tid_t tid, void *buf, size_t buf_size); - /// Reads generic floating point registers into the specified buffer. + /// Reads all floating point registers into the specified buffer. /// FIXME: The FreeBSD implementation of this function should use tid in order /// to enable support for debugging threaded programs. bool ReadFPR(lldb::tid_t tid, void *buf, size_t buf_size); - /// Reads the specified register set into the specified buffer. - /// For instance, the extended floating-point register set. - bool - ReadRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); - /// Writes all general purpose registers into the specified buffer. /// FIXME: The FreeBSD implementation of this function should use tid in order /// to enable support for debugging threaded programs. bool WriteGPR(lldb::tid_t tid, void *buf, size_t buf_size); - /// Writes generic floating point registers into the specified buffer. + /// Writes all floating point registers into the specified buffer. /// FIXME: The FreeBSD implementation of this function should use tid in order /// to enable support for debugging threaded programs. bool - WriteFPR(lldb::tid_t tid, void *buf, size_t buf_size); - - /// Writes the specified register set into the specified buffer. - /// For instance, the extended floating-point register set. - bool - WriteRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); + WriteFPR(lldb::tid_t tid, void *buf); /// Writes a siginfo_t structure corresponding to the given thread ID to the /// memory region pointed to by @p siginfo. diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp index 7e8ab68..6528b7e 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -109,13 +109,6 @@ static void PtraceDisplayBytes(__ptrace_request &req, void *data, size_t data_si verbose_log->Printf("PTRACE_SETSIGINFO %s", buf.GetData()); break; } - case PTRACE_SETREGSET: - { - // Extract iov_base from data, which is a pointer to the struct IOVEC - DisplayBytes(buf, *(void **)data, data_size); - verbose_log->Printf("PTRACE_SETREGSET %s", buf.GetData()); - break; - } default: { } @@ -140,10 +133,7 @@ PtraceWrapper(__ptrace_request req, pid_t pid, void *addr, void *data, size_t da PtraceDisplayBytes(req, data, data_size); errno = 0; - if (req == PTRACE_GETREGSET || req == PTRACE_SETREGSET) - result = ptrace(req, pid, *(unsigned int *)addr, data); - else - result = ptrace(req, pid, addr, data); + result = ptrace(req, pid, addr, data); PtraceDisplayBytes(req, data, data_size); @@ -169,12 +159,8 @@ PtraceWrapper(__ptrace_request req, pid_t pid, void *addr, void *data, size_t da extern long PtraceWrapper(__ptrace_request req, pid_t pid, void *addr, void *data, size_t data_size) { - long result = 0; errno = 0; - if (req == PTRACE_GETREGSET || req == PTRACE_SETREGSET) - result = ptrace(req, pid, *(unsigned int *)addr, data); - else - result = ptrace(req, pid, addr, data); + long result = ptrace(req, pid, addr, data); return result; } @@ -570,35 +556,6 @@ ReadFPROperation::Execute(ProcessMonitor *monitor) } //------------------------------------------------------------------------------ -/// @class ReadRegisterSetOperation -/// @brief Implements ProcessMonitor::ReadRegisterSet. -class ReadRegisterSetOperation : public Operation -{ -public: - ReadRegisterSetOperation(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset, bool &result) - : m_tid(tid), m_buf(buf), m_buf_size(buf_size), m_regset(regset), m_result(result) - { } - - void Execute(ProcessMonitor *monitor); - -private: - lldb::tid_t m_tid; - void *m_buf; - size_t m_buf_size; - const unsigned int m_regset; - bool &m_result; -}; - -void -ReadRegisterSetOperation::Execute(ProcessMonitor *monitor) -{ - if (PTRACE(PTRACE_GETREGSET, m_tid, (void *)&m_regset, m_buf, m_buf_size) < 0) - m_result = false; - else - m_result = true; -} - -//------------------------------------------------------------------------------ /// @class WriteGPROperation /// @brief Implements ProcessMonitor::WriteGPR. class WriteGPROperation : public Operation @@ -655,35 +612,6 @@ WriteFPROperation::Execute(ProcessMonitor *monitor) } //------------------------------------------------------------------------------ -/// @class WriteRegisterSetOperation -/// @brief Implements ProcessMonitor::WriteRegisterSet. -class WriteRegisterSetOperation : public Operation -{ -public: - WriteRegisterSetOperation(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset, bool &result) - : m_tid(tid), m_buf(buf), m_buf_size(buf_size), m_regset(regset), m_result(result) - { } - - void Execute(ProcessMonitor *monitor); - -private: - lldb::tid_t m_tid; - void *m_buf; - size_t m_buf_size; - const unsigned int m_regset; - bool &m_result; -}; - -void -WriteRegisterSetOperation::Execute(ProcessMonitor *monitor) -{ - if (PTRACE(PTRACE_SETREGSET, m_tid, (void *)&m_regset, m_buf, m_buf_size) < 0) - m_result = false; - else - m_result = true; -} - -//------------------------------------------------------------------------------ /// @class ResumeOperation /// @brief Implements ProcessMonitor::Resume. class ResumeOperation : public Operation @@ -1736,15 +1664,6 @@ ProcessMonitor::ReadFPR(lldb::tid_t tid, void *buf, size_t buf_size) } bool -ProcessMonitor::ReadRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset) -{ - bool result; - ReadRegisterSetOperation op(tid, buf, buf_size, regset, result); - DoOperation(&op); - return result; -} - -bool ProcessMonitor::WriteGPR(lldb::tid_t tid, void *buf, size_t buf_size) { bool result; @@ -1763,15 +1682,6 @@ ProcessMonitor::WriteFPR(lldb::tid_t tid, void *buf, size_t buf_size) } bool -ProcessMonitor::WriteRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset) -{ - bool result; - WriteRegisterSetOperation op(tid, buf, buf_size, regset, result); - DoOperation(&op); - return result; -} - -bool ProcessMonitor::Resume(lldb::tid_t tid, uint32_t signo) { bool result; diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.h b/lldb/source/Plugins/Process/Linux/ProcessMonitor.h index c446dcd..aa01478 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.h +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.h @@ -122,28 +122,18 @@ public: bool ReadGPR(lldb::tid_t tid, void *buf, size_t buf_size); - /// Reads generic floating point registers into the specified buffer. + /// Reads all floating point registers into the specified buffer. bool ReadFPR(lldb::tid_t tid, void *buf, size_t buf_size); - /// Reads the specified register set into the specified buffer. - /// For instance, the extended floating-point register set. - bool - ReadRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); - /// Writes all general purpose registers into the specified buffer. bool WriteGPR(lldb::tid_t tid, void *buf, size_t buf_size); - /// Writes generic floating point registers into the specified buffer. + /// Writes all floating point registers into the specified buffer. bool WriteFPR(lldb::tid_t tid, void *buf, size_t buf_size); - /// Writes the specified register set into the specified buffer. - /// For instance, the extended floating-point register set. - bool - WriteRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); - /// Writes a siginfo_t structure corresponding to the given thread ID to the /// memory region pointed to by @p siginfo. bool -- 2.7.4