Use PTRACE_GETREGSET for any arch in createdump (#22388)
authorSwift Kim <swift.kim@samsung.com>
Tue, 4 Feb 2020 23:04:33 +0000 (08:04 +0900)
committerGitHub <noreply@github.com>
Tue, 4 Feb 2020 23:04:33 +0000 (15:04 -0800)
Also ignore PTRACE_GETREGSET (NT_FPREGSET) failures for arm processes on
aarch64 kernels.

src/coreclr/src/debug/createdump/threadinfo.cpp

index 1651879..069db0a 100644 (file)
@@ -196,7 +196,6 @@ ThreadInfo::UnwindThread(CrashInfo& crashInfo, IXCLRDataProcess* pClrDataProcess
 bool
 ThreadInfo::GetRegistersWithPTrace()
 {
-#if defined(__aarch64__)
     struct iovec gpRegsVec = { &m_gpRegisters, sizeof(m_gpRegisters) };
     if (ptrace((__ptrace_request)PTRACE_GETREGSET, m_tid, NT_PRSTATUS, &gpRegsVec) == -1)
     {
@@ -208,21 +207,15 @@ ThreadInfo::GetRegistersWithPTrace()
     struct iovec fpRegsVec = { &m_fpRegisters, sizeof(m_fpRegisters) };
     if (ptrace((__ptrace_request)PTRACE_GETREGSET, m_tid, NT_FPREGSET, &fpRegsVec) == -1)
     {
+#if defined(__arm__)
+        // Some aarch64 kernels may not support NT_FPREGSET for arm processes. We treat this failure as non-fatal.
+#else
         fprintf(stderr, "ptrace(PTRACE_GETREGSET, %d, NT_FPREGSET) FAILED %d (%s)\n", m_tid, errno, strerror(errno));
         return false;
+#endif
     }
     assert(sizeof(m_fpRegisters) == fpRegsVec.iov_len);
-#else
-    if (ptrace((__ptrace_request)PTRACE_GETREGS, m_tid, nullptr, &m_gpRegisters) == -1)
-    {
-        fprintf(stderr, "ptrace(GETREGS, %d) FAILED %d (%s)\n", m_tid, errno, strerror(errno));
-        return false;
-    }
-    if (ptrace((__ptrace_request)PTRACE_GETFPREGS, m_tid, nullptr, &m_fpRegisters) == -1)
-    {
-        fprintf(stderr, "ptrace(GETFPREGS, %d) FAILED %d (%s)\n", m_tid, errno, strerror(errno));
-        return false;
-    }
+
 #if defined(__i386__)
     if (ptrace((__ptrace_request)PTRACE_GETFPXREGS, m_tid, nullptr, &m_fpxRegisters) == -1)
     {
@@ -241,7 +234,6 @@ ThreadInfo::GetRegistersWithPTrace()
         return false;
     }
 #endif
-#endif
     return true;
 }