Author: tfiala Date: Thu Aug 21 11:34:03 2014 New Revision: 216185 URL: http://llvm.org/viewvc/llvm-project?rev=216185&view=rev Log: Enable more Linux aarch64 PTRACE support for local and remote debugging.
See http://reviews.llvm.org/D4803 for more details. Change by Paul Osmialowski. Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=216185&r1=216184&r2=216185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Thu Aug 21 11:34:03 2014 @@ -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 } //------------------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=216185&r1=216184&r2=216185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Thu Aug 21 11:34:03 2014 @@ -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, 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 } _______________________________________________ lldb-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
