<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks.  Patch checked in to ToT.<br><div><div>On Sep 19, 2011, at 11:39 AM, Filipe Cabecinhas wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">That patch has a bug by using the constant "<span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 204); ">x86_AVX_STATE64"</span><div>
<font class="Apple-style-span" color="#222222" face="arial, sans-serif">Here is a fix.</font></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"><br></font></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif">Regards,</font></div>
<div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"><br clear="all"></font>  Filipe<br><br>
<br><br><div class="gmail_quote">On Fri, Sep 16, 2011 at 22:59, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com">gclayton@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Author: gclayton<br>
Date: Sat Sep 17 00:59:37 2011<br>
New Revision: 139982<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=139982&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=139982&view=rev</a><br>
Log:<br>
Added more logging, and renamed FPR to FPU in a the register set/flavor enum.<br>
<br>
<br>
Modified:<br>
    lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp<br>
    lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h<br>
    lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp<br>
    lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h<br>
<br>
Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=139982&r1=139981&r2=139982&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=139982&r1=139981&r2=139982&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original)<br>
+++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Sat Sep 17 00:59:37 2011<br>
@@ -463,12 +463,18 @@<br>
             if (CPUHasAVX() || FORCE_AVX_REGS)<br>
             {<br>
                 mach_msg_type_number_t count = e_regSetWordSizeAVX;<br>
-                m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count));<br>
+                m_state.SetError (e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count));<br>
+                DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, %u (%u passed in)) => 0x%8.8x",<br>
+                                  m_thread->ThreadID(), __i386_AVX_STATE, count, e_regSetWordSizeAVX,<br>
+                                  m_state.GetError(e_regSetFPU, Read));<br>
             }<br>
             else<br>
             {<br>
-                mach_msg_type_number_t count = e_regSetWordSizeFPR;<br>
+                mach_msg_type_number_t count = e_regSetWordSizeFPU;<br>
                 m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, &count));<br>
+                DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &fpu, %u (%u passed in) => 0x%8.8x",<br>
+                                  m_thread->ThreadID(), __i386_FLOAT_STATE, count, e_regSetWordSizeFPU,<br>
+                                  m_state.GetError(e_regSetFPU, Read));<br>
             }<br>
         }<br>
     }<br>
@@ -506,7 +512,7 @@<br>
         if (CPUHasAVX() || FORCE_AVX_REGS)<br>
             m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, e_regSetWordSizeAVX));<br>
         else<br>
-            m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPR));<br>
+            m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPU));<br>
         return m_state.GetError(e_regSetFPU, Write);<br>
     }<br>
 }<br>
@@ -1448,9 +1454,27 @@<br>
             size = buf_len;<br>
<br>
         bool force = false;<br>
-        if (GetGPRState(force) | GetFPUState(force) | GetEXCState(force))<br>
-            return 0;<br>
-        ::memcpy (buf, &m_state.context, size);<br>
+        kern_return_t kret;<br>
+        if ((kret = GetGPRState(force)) != KERN_SUCCESS)<br>
+        {<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to read: %u ", buf, buf_len, kret);<br>
+            size = 0;<br>
+        }<br>
+        else if ((kret = GetFPUState(force)) != KERN_SUCCESS)<br>
+        {<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: %s regs failed to read: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret);<br>

+            size = 0;<br>
+        }<br>
+        else if ((kret = GetEXCState(force)) != KERN_SUCCESS)<br>
+        {<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: EXC regs failed to read: %u", buf, buf_len, kret);<br>
+            size = 0;<br>
+        }<br>
+        else<br>
+        {<br>
+            // Success<br>
+            ::memcpy (buf, &m_state.context, size);<br>
+        }<br>
     }<br>
     DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size);<br>
     // Return the size of the register context even if NULL was passed in<br>
@@ -1470,9 +1494,13 @@<br>
             size = buf_len;<br>
<br>
         ::memcpy (&m_state.context, buf, size);<br>
-        SetGPRState();<br>
-        SetFPUState();<br>
-        SetEXCState();<br>
+        kern_return_t kret;<br>
+        if ((kret = SetGPRState()) != KERN_SUCCESS)<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to write: %u", buf, buf_len, kret);<br>
+        if ((kret = SetFPUState()) != KERN_SUCCESS)<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: %s regs failed to write: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret);<br>

+        if ((kret = SetEXCState()) != KERN_SUCCESS)<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: EXP regs failed to write: %u", buf, buf_len, kret);<br>
     }<br>
     DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size);<br>
     return size;<br>
<br>
Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=139982&r1=139981&r2=139982&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=139982&r1=139981&r2=139982&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h (original)<br>
+++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Sat Sep 17 00:59:37 2011<br>
@@ -92,7 +92,7 @@<br>
     typedef enum RegisterSetWordSizeTag<br>
     {<br>
         e_regSetWordSizeGPR = sizeof(GPR) / sizeof(int),<br>
-        e_regSetWordSizeFPR = sizeof(FPU) / sizeof(int),<br>
+        e_regSetWordSizeFPU = sizeof(FPU) / sizeof(int),<br>
         e_regSetWordSizeEXC = sizeof(EXC) / sizeof(int),<br>
         e_regSetWordSizeAVX = sizeof(AVX) / sizeof(int),<br>
         e_regSetWordSizeDBG = sizeof(DBG) / sizeof(int)<br>
<br>
Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=139982&r1=139981&r2=139982&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=139982&r1=139981&r2=139982&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original)<br>
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Sat Sep 17 00:59:37 2011<br>
@@ -369,11 +369,17 @@<br>
             {<br>
                 mach_msg_type_number_t count = e_regSetWordSizeAVX;<br>
                 m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count));<br>
+                DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, %u (%u passed in) carp) => 0x%8.8x",<br>
+                                  m_thread->ThreadID(), x86_AVX_STATE64, (uint32_t)count,<br>
+                                  e_regSetWordSizeAVX, m_state.GetError(e_regSetFPU, Read));<br>
             }<br>
             else<br>
             {<br>
-                mach_msg_type_number_t count = e_regSetWordSizeFPR;<br>
+                mach_msg_type_number_t count = e_regSetWordSizeFPU;<br>
                 m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, &count));<br>
+                DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &fpu, %u (%u passed in) => 0x%8.8x",<br>
+                                  m_thread->ThreadID(), __x86_64_FLOAT_STATE, (uint32_t)count,<br>
+                                  e_regSetWordSizeFPU, m_state.GetError(e_regSetFPU, Read));<br>
             }<br>
         }<br>
     }<br>
@@ -434,7 +440,7 @@<br>
         }<br>
         else<br>
         {<br>
-            m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPR));<br>
+            m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPU));<br>
             return m_state.GetError(e_regSetFPU, Write);<br>
         }<br>
     }<br>
@@ -1714,9 +1720,29 @@<br>
             size = buf_len;<br>
<br>
         bool force = false;<br>
-        if (GetGPRState(force) | GetFPUState(force) | GetEXCState(force))<br>
-            return 0;<br>
-        ::memcpy (buf, &m_state.context, size);<br>
+        kern_return_t kret;<br>
+        if ((kret = GetGPRState(force)) != KERN_SUCCESS)<br>
+        {<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to read: %u ", buf, buf_len, kret);<br>
+            size = 0;<br>
+        }<br>
+        else<br>
+        if ((kret = GetFPUState(force)) != KERN_SUCCESS)<br>
+        {<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: %s regs failed to read: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret);<br>

+            size = 0;<br>
+        }<br>
+        else<br>
+        if ((kret = GetEXCState(force)) != KERN_SUCCESS)<br>
+        {<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: EXC regs failed to read: %u", buf, buf_len, kret);<br>
+            size = 0;<br>
+        }<br>
+        else<br>
+        {<br>
+            // Success<br>
+            ::memcpy (buf, &m_state.context, size);<br>
+        }<br>
     }<br>
     DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size);<br>
     // Return the size of the register context even if NULL was passed in<br>
@@ -1736,9 +1762,13 @@<br>
             size = buf_len;<br>
<br>
         ::memcpy (&m_state.context, buf, size);<br>
-        SetGPRState();<br>
-        SetFPUState();<br>
-        SetEXCState();<br>
+        kern_return_t kret;<br>
+        if ((kret = SetGPRState()) != KERN_SUCCESS)<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to write: %u", buf, buf_len, kret);<br>
+        if ((kret = SetFPUState()) != KERN_SUCCESS)<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: %s regs failed to write: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret);<br>

+        if ((kret = SetEXCState()) != KERN_SUCCESS)<br>
+            DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: EXP regs failed to write: %u", buf, buf_len, kret);<br>
     }<br>
     DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size);<br>
     return size;<br>
<br>
Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h?rev=139982&r1=139981&r2=139982&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h?rev=139982&r1=139981&r2=139982&view=diff</a><br>

==============================================================================<br>
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h (original)<br>
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Sat Sep 17 00:59:37 2011<br>
@@ -91,7 +91,7 @@<br>
     typedef enum RegisterSetWordSizeTag<br>
     {<br>
         e_regSetWordSizeGPR = sizeof(GPR) / sizeof(int),<br>
-        e_regSetWordSizeFPR = sizeof(FPU) / sizeof(int),<br>
+        e_regSetWordSizeFPU = sizeof(FPU) / sizeof(int),<br>
         e_regSetWordSizeEXC = sizeof(EXC) / sizeof(int),<br>
         e_regSetWordSizeAVX = sizeof(AVX) / sizeof(int),<br>
         e_regSetWordSizeDBG = sizeof(DBG) / sizeof(int)<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listino/lldb-commits</a><br>
</blockquote></div><br></div>
<span><fix-r139982.patch></span>_______________________________________________<br>lldb-commits mailing list<br><a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits<br></blockquote></div><br></body></html>