[Lldb-commits] [lldb] r139982 - in /lldb/trunk/tools/debugserver/source/MacOSX: i386/DNBArchImplI386.cpp i386/DNBArchImplI386.h x86_64/DNBArchImplX86_64.cpp x86_64/DNBArchImplX86_64.h
Johnny Chen
johnny.chen at apple.com
Mon Sep 19 11:56:08 PDT 2011
Thanks. Patch checked in to ToT.
On Sep 19, 2011, at 11:39 AM, Filipe Cabecinhas wrote:
> That patch has a bug by using the constant "x86_AVX_STATE64"
> Here is a fix.
>
> Regards,
>
> Filipe
>
>
>
> On Fri, Sep 16, 2011 at 22:59, Greg Clayton <gclayton at apple.com> wrote:
> Author: gclayton
> Date: Sat Sep 17 00:59:37 2011
> New Revision: 139982
>
> URL: http://llvm.org/viewvc/llvm-project?rev=139982&view=rev
> Log:
> Added more logging, and renamed FPR to FPU in a the register set/flavor enum.
>
>
> Modified:
> lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
> lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
> lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
> lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h
>
> Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=139982&r1=139981&r2=139982&view=diff
> ==============================================================================
> --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original)
> +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Sat Sep 17 00:59:37 2011
> @@ -463,12 +463,18 @@
> if (CPUHasAVX() || FORCE_AVX_REGS)
> {
> mach_msg_type_number_t count = e_regSetWordSizeAVX;
> - m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count));
> + m_state.SetError (e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count));
> + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, %u (%u passed in)) => 0x%8.8x",
> + m_thread->ThreadID(), __i386_AVX_STATE, count, e_regSetWordSizeAVX,
> + m_state.GetError(e_regSetFPU, Read));
> }
> else
> {
> - mach_msg_type_number_t count = e_regSetWordSizeFPR;
> + mach_msg_type_number_t count = e_regSetWordSizeFPU;
> 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));
> + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &fpu, %u (%u passed in) => 0x%8.8x",
> + m_thread->ThreadID(), __i386_FLOAT_STATE, count, e_regSetWordSizeFPU,
> + m_state.GetError(e_regSetFPU, Read));
> }
> }
> }
> @@ -506,7 +512,7 @@
> if (CPUHasAVX() || FORCE_AVX_REGS)
> 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));
> else
> - 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));
> + 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));
> return m_state.GetError(e_regSetFPU, Write);
> }
> }
> @@ -1448,9 +1454,27 @@
> size = buf_len;
>
> bool force = false;
> - if (GetGPRState(force) | GetFPUState(force) | GetEXCState(force))
> - return 0;
> - ::memcpy (buf, &m_state.context, size);
> + kern_return_t kret;
> + if ((kret = GetGPRState(force)) != KERN_SUCCESS)
> + {
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to read: %u ", buf, buf_len, kret);
> + size = 0;
> + }
> + else if ((kret = GetFPUState(force)) != KERN_SUCCESS)
> + {
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: %s regs failed to read: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret);
> + size = 0;
> + }
> + else if ((kret = GetEXCState(force)) != KERN_SUCCESS)
> + {
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: EXC regs failed to read: %u", buf, buf_len, kret);
> + size = 0;
> + }
> + else
> + {
> + // Success
> + ::memcpy (buf, &m_state.context, size);
> + }
> }
> DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size);
> // Return the size of the register context even if NULL was passed in
> @@ -1470,9 +1494,13 @@
> size = buf_len;
>
> ::memcpy (&m_state.context, buf, size);
> - SetGPRState();
> - SetFPUState();
> - SetEXCState();
> + kern_return_t kret;
> + if ((kret = SetGPRState()) != KERN_SUCCESS)
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to write: %u", buf, buf_len, kret);
> + if ((kret = SetFPUState()) != KERN_SUCCESS)
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: %s regs failed to write: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret);
> + if ((kret = SetEXCState()) != KERN_SUCCESS)
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: EXP regs failed to write: %u", buf, buf_len, kret);
> }
> DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size);
> return size;
>
> Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=139982&r1=139981&r2=139982&view=diff
> ==============================================================================
> --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h (original)
> +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Sat Sep 17 00:59:37 2011
> @@ -92,7 +92,7 @@
> typedef enum RegisterSetWordSizeTag
> {
> e_regSetWordSizeGPR = sizeof(GPR) / sizeof(int),
> - e_regSetWordSizeFPR = sizeof(FPU) / sizeof(int),
> + e_regSetWordSizeFPU = sizeof(FPU) / sizeof(int),
> e_regSetWordSizeEXC = sizeof(EXC) / sizeof(int),
> e_regSetWordSizeAVX = sizeof(AVX) / sizeof(int),
> e_regSetWordSizeDBG = sizeof(DBG) / sizeof(int)
>
> Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
> URL: 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
> ==============================================================================
> --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original)
> +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Sat Sep 17 00:59:37 2011
> @@ -369,11 +369,17 @@
> {
> mach_msg_type_number_t count = e_regSetWordSizeAVX;
> 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));
> + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, %u (%u passed in) carp) => 0x%8.8x",
> + m_thread->ThreadID(), x86_AVX_STATE64, (uint32_t)count,
> + e_regSetWordSizeAVX, m_state.GetError(e_regSetFPU, Read));
> }
> else
> {
> - mach_msg_type_number_t count = e_regSetWordSizeFPR;
> + mach_msg_type_number_t count = e_regSetWordSizeFPU;
> 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));
> + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &fpu, %u (%u passed in) => 0x%8.8x",
> + m_thread->ThreadID(), __x86_64_FLOAT_STATE, (uint32_t)count,
> + e_regSetWordSizeFPU, m_state.GetError(e_regSetFPU, Read));
> }
> }
> }
> @@ -434,7 +440,7 @@
> }
> else
> {
> - 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));
> + 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));
> return m_state.GetError(e_regSetFPU, Write);
> }
> }
> @@ -1714,9 +1720,29 @@
> size = buf_len;
>
> bool force = false;
> - if (GetGPRState(force) | GetFPUState(force) | GetEXCState(force))
> - return 0;
> - ::memcpy (buf, &m_state.context, size);
> + kern_return_t kret;
> + if ((kret = GetGPRState(force)) != KERN_SUCCESS)
> + {
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to read: %u ", buf, buf_len, kret);
> + size = 0;
> + }
> + else
> + if ((kret = GetFPUState(force)) != KERN_SUCCESS)
> + {
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: %s regs failed to read: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret);
> + size = 0;
> + }
> + else
> + if ((kret = GetEXCState(force)) != KERN_SUCCESS)
> + {
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: EXC regs failed to read: %u", buf, buf_len, kret);
> + size = 0;
> + }
> + else
> + {
> + // Success
> + ::memcpy (buf, &m_state.context, size);
> + }
> }
> DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size);
> // Return the size of the register context even if NULL was passed in
> @@ -1736,9 +1762,13 @@
> size = buf_len;
>
> ::memcpy (&m_state.context, buf, size);
> - SetGPRState();
> - SetFPUState();
> - SetEXCState();
> + kern_return_t kret;
> + if ((kret = SetGPRState()) != KERN_SUCCESS)
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to write: %u", buf, buf_len, kret);
> + if ((kret = SetFPUState()) != KERN_SUCCESS)
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: %s regs failed to write: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret);
> + if ((kret = SetEXCState()) != KERN_SUCCESS)
> + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: EXP regs failed to write: %u", buf, buf_len, kret);
> }
> DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size);
> return size;
>
> Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h
> URL: 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
> ==============================================================================
> --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h (original)
> +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Sat Sep 17 00:59:37 2011
> @@ -91,7 +91,7 @@
> typedef enum RegisterSetWordSizeTag
> {
> e_regSetWordSizeGPR = sizeof(GPR) / sizeof(int),
> - e_regSetWordSizeFPR = sizeof(FPU) / sizeof(int),
> + e_regSetWordSizeFPU = sizeof(FPU) / sizeof(int),
> e_regSetWordSizeEXC = sizeof(EXC) / sizeof(int),
> e_regSetWordSizeAVX = sizeof(AVX) / sizeof(int),
> e_regSetWordSizeDBG = sizeof(DBG) / sizeof(int)
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listino/lldb-commits
>
> <fix-r139982.patch>_______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20110919/c6184d85/attachment.html>
More information about the lldb-commits
mailing list