diff options
-rw-r--r-- | lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp | 54 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp | 66 |
2 files changed, 105 insertions, 15 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index 32915d2b4e4..2cd0a138883 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -20,12 +20,18 @@ #include <linux/unistd.h> #include <sys/personality.h> #include <sys/ptrace.h> +#include <sys/uio.h> #include <sys/socket.h> #include <sys/syscall.h> #include <sys/types.h> #include <sys/user.h> #include <sys/wait.h> +#if defined (__arm64__) || defined (__aarch64__) +// NT_PRSTATUS and NT_FPREGSET definition +#include <elf.h> +#endif + // C++ Includes #include <fstream> #include <string> @@ -662,10 +668,22 @@ namespace void ReadGPROperation::Execute(NativeProcessLinux *monitor) { +#if defined (__arm64__) || defined (__aarch64__) + int regset = NT_PRSTATUS; + struct iovec ioVec; + + ioVec.iov_base = m_buf; + ioVec.iov_len = m_buf_size; + if (PTRACE(PTRACE_GETREGSET, m_tid, ®set, &ioVec, m_buf_size) < 0) + m_result = false; + else + m_result = true; +#else if (PTRACE(PTRACE_GETREGS, m_tid, NULL, m_buf, m_buf_size) < 0) m_result = false; else m_result = true; +#endif } //------------------------------------------------------------------------------ @@ -690,10 +708,22 @@ namespace void ReadFPROperation::Execute(NativeProcessLinux *monitor) { +#if defined (__arm64__) || defined (__aarch64__) + int regset = NT_FPREGSET; + struct iovec ioVec; + + ioVec.iov_base = m_buf; + ioVec.iov_len = m_buf_size; + if (PTRACE(PTRACE_GETREGSET, m_tid, ®set, &ioVec, m_buf_size) < 0) + m_result = false; + else + m_result = true; +#else if (PTRACE(PTRACE_GETFPREGS, m_tid, NULL, m_buf, m_buf_size) < 0) m_result = false; else m_result = true; +#endif } //------------------------------------------------------------------------------ @@ -747,10 +777,22 @@ namespace void WriteGPROperation::Execute(NativeProcessLinux *monitor) { +#if defined (__arm64__) || defined (__aarch64__) + int regset = NT_PRSTATUS; + struct iovec ioVec; + + ioVec.iov_base = m_buf; + ioVec.iov_len = m_buf_size; + if (PTRACE(PTRACE_SETREGSET, m_tid, ®set, &ioVec, m_buf_size) < 0) + m_result = false; + else + m_result = true; +#else if (PTRACE(PTRACE_SETREGS, m_tid, NULL, m_buf, m_buf_size) < 0) m_result = false; else m_result = true; +#endif } //------------------------------------------------------------------------------ @@ -775,10 +817,22 @@ namespace void WriteFPROperation::Execute(NativeProcessLinux *monitor) { +#if defined (__arm64__) || defined (__aarch64__) + int regset = NT_FPREGSET; + struct iovec ioVec; + + ioVec.iov_base = m_buf; + ioVec.iov_len = m_buf_size; + if (PTRACE(PTRACE_SETREGSET, m_tid, ®set, &ioVec, m_buf_size) < 0) + m_result = false; + else + m_result = true; +#else if (PTRACE(PTRACE_SETFPREGS, m_tid, NULL, m_buf, m_buf_size) < 0) m_result = false; else m_result = true; +#endif } //------------------------------------------------------------------------------ diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp index 42a0aa51f4c..048a517d4f1 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -17,12 +17,18 @@ #include <unistd.h> #include <sys/personality.h> #include <sys/ptrace.h> +#include <sys/uio.h> #include <sys/socket.h> #include <sys/syscall.h> #include <sys/types.h> #include <sys/user.h> #include <sys/wait.h> +#if defined (__arm64__) || defined (__aarch64__) +// NT_PRSTATUS and NT_FPREGSET definition +#include <elf.h> +#endif + // C++ Includes // Other libraries and framework includes #include "lldb/Core/Debugger.h" @@ -124,15 +130,13 @@ static void PtraceDisplayBytes(int &req, void *data, size_t data_size) verbose_log->Printf("PTRACE_POKEUSER %s", buf.GetData()); break; } -#ifdef PT_SETREGS +#if !defined (__arm64__) && !defined (__aarch64__) case PTRACE_SETREGS: { DisplayBytes(buf, data, data_size); verbose_log->Printf("PTRACE_SETREGS %s", buf.GetData()); break; } -#endif -#ifdef PT_SETFPREGS case PTRACE_SETFPREGS: { DisplayBytes(buf, data, data_size); @@ -570,13 +574,21 @@ private: void ReadGPROperation::Execute(ProcessMonitor *monitor) { -#ifdef PT_GETREGS - if (PTRACE(PTRACE_GETREGS, m_tid, NULL, m_buf, m_buf_size) < 0) +#if defined (__arm64__) || defined (__aarch64__) + int regset = NT_PRSTATUS; + struct iovec ioVec; + + ioVec.iov_base = m_buf; + ioVec.iov_len = m_buf_size; + if (PTRACE(PTRACE_GETREGSET, m_tid, ®set, &ioVec, m_buf_size) < 0) m_result = false; else m_result = true; #else - m_result = false; + if (PTRACE(PTRACE_GETREGS, m_tid, NULL, m_buf, m_buf_size) < 0) + m_result = false; + else + m_result = true; #endif } @@ -602,13 +614,21 @@ private: void ReadFPROperation::Execute(ProcessMonitor *monitor) { -#ifdef PT_GETFPREGS - if (PTRACE(PTRACE_GETFPREGS, m_tid, NULL, m_buf, m_buf_size) < 0) +#if defined (__arm64__) || defined (__aarch64__) + int regset = NT_FPREGSET; + struct iovec ioVec; + + ioVec.iov_base = m_buf; + ioVec.iov_len = m_buf_size; + if (PTRACE(PTRACE_GETREGSET, m_tid, ®set, &ioVec, m_buf_size) < 0) m_result = false; else m_result = true; #else - m_result = false; + if (PTRACE(PTRACE_GETFPREGS, m_tid, NULL, m_buf, m_buf_size) < 0) + m_result = false; + else + m_result = true; #endif } @@ -663,13 +683,21 @@ private: void WriteGPROperation::Execute(ProcessMonitor *monitor) { -#ifdef PT_SETREGS - if (PTRACE(PTRACE_SETREGS, m_tid, NULL, m_buf, m_buf_size) < 0) +#if defined (__arm64__) || defined (__aarch64__) + int regset = NT_PRSTATUS; + struct iovec ioVec; + + ioVec.iov_base = m_buf; + ioVec.iov_len = m_buf_size; + if (PTRACE(PTRACE_SETREGSET, m_tid, ®set, &ioVec, m_buf_size) < 0) m_result = false; else m_result = true; #else - m_result = false; + if (PTRACE(PTRACE_SETREGS, m_tid, NULL, m_buf, m_buf_size) < 0) + m_result = false; + else + m_result = true; #endif } @@ -695,13 +723,21 @@ private: void WriteFPROperation::Execute(ProcessMonitor *monitor) { -#ifdef PT_SETFPREGS - if (PTRACE(PTRACE_SETFPREGS, m_tid, NULL, m_buf, m_buf_size) < 0) +#if defined (__arm64__) || defined (__aarch64__) + int regset = NT_FPREGSET; + struct iovec ioVec; + + ioVec.iov_base = m_buf; + ioVec.iov_len = m_buf_size; + if (PTRACE(PTRACE_SETREGSET, m_tid, ®set, &ioVec, m_buf_size) < 0) m_result = false; else m_result = true; #else - m_result = false; + if (PTRACE(PTRACE_SETFPREGS, m_tid, NULL, m_buf, m_buf_size) < 0) + m_result = false; + else + m_result = true; #endif } |